Example usage for org.hibernate Session load

List of usage examples for org.hibernate Session load

Introduction

In this page you can find the example usage for org.hibernate Session load.

Prototype

Object load(String entityName, Serializable id, LockOptions lockOptions);

Source Link

Document

Return the persistent instance of the given entity class with the given identifier, obtaining the specified lock mode, assuming the instance exists.

Usage

From source file:com.jdon.persistence.hibernate.HibernateTemplate.java

License:Apache License

public Object load(final Class entityClass, final Serializable id, final LockMode lockMode) throws Exception {

    return doHibernate(new HibernateCallback() {
        public Object execute(Session session) throws HibernateException {
            if (lockMode != null) {
                return session.load(entityClass, id, lockMode);
            } else {
                return session.load(entityClass, id);
            }/*  w w w  .j a  va2  s  . co m*/
        }
    });
}

From source file:com.jdon.persistence.hibernate.HibernateTemplate.java

License:Apache License

public Object load(final String entityName, final Serializable id, final LockMode lockMode) throws Exception {

    return doHibernate(new HibernateCallback() {
        public Object execute(Session session) throws HibernateException {
            if (lockMode != null) {
                return session.load(entityName, id, lockMode);
            } else {
                return session.load(entityName, id);
            }//from  ww w  .j a  v  a  2  s  . c om
        }
    });
}