use of org.hibernate.event.spi.LoadEvent in project hibernate-orm by hibernate.
the class SessionImpl method load.
// load()/get() operations ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@Override
public void load(Object object, Serializable id) throws HibernateException {
LoadEvent event = loadEvent;
loadEvent = null;
if (event == null) {
event = new LoadEvent(id, object, this);
} else {
event.setEntityClassName(null);
event.setEntityId(id);
event.setInstanceToLoad(object);
event.setLockMode(LoadEvent.DEFAULT_LOCK_MODE);
event.setLockScope(LoadEvent.DEFAULT_LOCK_OPTIONS.getScope());
event.setLockTimeout(LoadEvent.DEFAULT_LOCK_OPTIONS.getTimeOut());
}
fireLoad(event, LoadEventListener.RELOAD);
if (loadEvent == null) {
event.setEntityClassName(null);
event.setEntityId(null);
event.setInstanceToLoad(null);
event.setResult(null);
loadEvent = event;
}
}
use of org.hibernate.event.spi.LoadEvent in project hibernate-orm by hibernate.
the class SessionImpl method internalLoad.
@Override
public final Object internalLoad(String entityName, Serializable id, boolean eager, boolean nullable) throws HibernateException {
// todo : remove
LoadEventListener.LoadType type = nullable ? LoadEventListener.INTERNAL_LOAD_NULLABLE : eager ? LoadEventListener.INTERNAL_LOAD_EAGER : LoadEventListener.INTERNAL_LOAD_LAZY;
LoadEvent event = loadEvent;
loadEvent = null;
event = recycleEventInstance(event, id, entityName);
fireLoad(event, type);
Object result = event.getResult();
if (!nullable) {
UnresolvableObjectException.throwIfNull(result, id, entityName);
}
if (loadEvent == null) {
event.setEntityClassName(null);
event.setEntityId(null);
event.setInstanceToLoad(null);
event.setResult(null);
loadEvent = event;
}
return result;
}
use of org.hibernate.event.spi.LoadEvent in project hibernate-orm by hibernate.
the class SessionImpl method immediateLoad.
/**
* Load the data for the object with the specified id into a newly created object.
* This is only called when lazily initializing a proxy.
* Do NOT return a proxy.
*/
@Override
public Object immediateLoad(String entityName, Serializable id) throws HibernateException {
if (log.isDebugEnabled()) {
EntityPersister persister = getFactory().getMetamodel().entityPersister(entityName);
log.debugf("Initializing proxy: %s", MessageHelper.infoString(persister, id, getFactory()));
}
LoadEvent event = loadEvent;
loadEvent = null;
event = recycleEventInstance(event, id, entityName);
fireLoad(event, LoadEventListener.IMMEDIATE_LOAD);
Object result = event.getResult();
if (loadEvent == null) {
event.setEntityClassName(null);
event.setEntityId(null);
event.setInstanceToLoad(null);
event.setResult(null);
loadEvent = event;
}
return result;
}
Aggregations