Java Code Examples for org.hibernate.persister.entity.EntityPersister#load()
The following examples show how to use
org.hibernate.persister.entity.EntityPersister#load() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DefaultLoadEventListener.java From lams with GNU General Public License v2.0 | 6 votes |
/** * Performs the process of loading an entity from the configured * underlying datasource. * * @param event The load event * @param persister The persister for the entity being requested for load * * @return The object loaded from the datasource, or null if not found. */ protected Object loadFromDatasource( final LoadEvent event, final EntityPersister persister) { Object entity = persister.load( event.getEntityId(), event.getInstanceToLoad(), event.getLockOptions(), event.getSession() ); if ( event.isAssociationFetch() && event.getSession().getFactory().getStatistics().isStatisticsEnabled() ) { event.getSession().getFactory().getStatistics().fetchEntity( event.getEntityClassName() ); } return entity; }
Example 2
Source File: DefaultLoadEventListener.java From cacheonix-core with GNU Lesser General Public License v2.1 | 6 votes |
/** * Performs the process of loading an entity from the configured * underlying datasource. * * @param event The load event * @param persister The persister for the entity being requested for load * @param keyToLoad The EntityKey representing the entity to be loaded. * @param options The load options. * @return The object loaded from the datasource, or null if not found. * @throws HibernateException */ protected Object loadFromDatasource( final LoadEvent event, final EntityPersister persister, final EntityKey keyToLoad, final LoadEventListener.LoadType options) throws HibernateException { final SessionImplementor source = event.getSession(); Object entity = persister.load( event.getEntityId(), event.getInstanceToLoad(), event.getLockMode(), source ); if ( event.isAssociationFetch() && source.getFactory().getStatistics().isStatisticsEnabled() ) { source.getFactory().getStatisticsImplementor().fetchEntity( event.getEntityClassName() ); } return entity; }
Example 3
Source File: StatelessSessionImpl.java From lams with GNU General Public License v2.0 | 4 votes |
@Override public void refresh(String entityName, Object entity, LockMode lockMode) { final EntityPersister persister = this.getEntityPersister( entityName, entity ); final Serializable id = persister.getIdentifier( entity, this ); if ( LOG.isTraceEnabled() ) { LOG.tracev( "Refreshing transient {0}", MessageHelper.infoString( persister, id, this.getFactory() ) ); } // TODO : can this ever happen??? // EntityKey key = new EntityKey( id, persister, source.getEntityMode() ); // if ( source.getPersistenceContext().getEntry( key ) != null ) { // throw new PersistentObjectException( // "attempted to refresh transient instance when persistent " + // "instance was already associated with the Session: " + // MessageHelper.infoString( persister, id, source.getFactory() ) // ); // } if ( persister.canWriteToCache() ) { final EntityDataAccess cacheAccess = persister.getCacheAccessStrategy(); if ( cacheAccess != null ) { final Object ck = cacheAccess.generateCacheKey( id, persister, getFactory(), getTenantIdentifier() ); cacheAccess.evict( ck ); } } String previousFetchProfile = this.getLoadQueryInfluencers().getInternalFetchProfile(); Object result = null; try { this.getLoadQueryInfluencers().setInternalFetchProfile( "refresh" ); result = persister.load( id, entity, getNullSafeLockMode( lockMode ), this ); } finally { this.getLoadQueryInfluencers().setInternalFetchProfile( previousFetchProfile ); } UnresolvableObjectException.throwIfNull( result, id, persister.getEntityName() ); }
Example 4
Source File: StatelessSessionImpl.java From cacheonix-core with GNU Lesser General Public License v2.1 | 4 votes |
public void refresh(String entityName, Object entity, LockMode lockMode) { final EntityPersister persister = this.getEntityPersister( entityName, entity ); final Serializable id = persister.getIdentifier( entity, getEntityMode() ); if ( log.isTraceEnabled() ) { log.trace( "refreshing transient " + MessageHelper.infoString( persister, id, this.getFactory() ) ); } // TODO : can this ever happen??? // EntityKey key = new EntityKey( id, persister, source.getEntityMode() ); // if ( source.getPersistenceContext().getEntry( key ) != null ) { // throw new PersistentObjectException( // "attempted to refresh transient instance when persistent " + // "instance was already associated with the Session: " + // MessageHelper.infoString( persister, id, source.getFactory() ) // ); // } if ( persister.hasCache() ) { final CacheKey ck = new CacheKey( id, persister.getIdentifierType(), persister.getRootEntityName(), this.getEntityMode(), this.getFactory() ); persister.getCache().remove(ck); } String previousFetchProfile = this.getFetchProfile(); Object result = null; try { this.setFetchProfile( "refresh" ); result = persister.load( id, entity, lockMode, this ); } finally { this.setFetchProfile( previousFetchProfile ); } UnresolvableObjectException.throwIfNull( result, id, persister.getEntityName() ); }