/** *//** * Coordinates the efforts to load a given entity. First, an attempt is * made to load the entity from the session-level cache. If not found there, * an attempt is made to locate it in second-level cache. Lastly, an * attempt is made to load it directly from the 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 loaded entity, or null. * @throws HibernateException */ protected Object doLoad( final LoadEvent event, final EntityPersister persister, final EntityKey keyToLoad, final LoadEventListener.LoadType options) throws HibernateException ...{ if ( log.isTraceEnabled() ) ...{ log.trace( "attempting to resolve: "+ MessageHelper.infoString( persister, event.getEntityId(), event.getSession().getFactory() ) ); } Object entity = loadFromSessionCache( event, keyToLoad, options ); if ( entity == REMOVED_ENTITY_MARKER ) ...{ log.debug( "load request found matching entity in context, but it is scheduled for removal; returning null" ); returnnull; } if ( entity == INCONSISTENT_RTN_CLASS_MARKER ) ...{ log.debug( "load request found matching entity in context, but the matched entity was of an inconsistent return type; returning null" ); returnnull; } if ( entity !=null ) ...{ if ( log.isTraceEnabled() ) ...{ log.trace( "resolved object in session cache: "+ MessageHelper.infoString( persister, event.getEntityId(), event.getSession().getFactory() ) ); } return entity; } entity = loadFromSecondLevelCache(event, persister, options); if ( entity !=null ) ...{ if ( log.isTraceEnabled() ) ...{ log.trace( "resolved object in second-level cache: "+ MessageHelper.infoString( persister, event.getEntityId(), event.getSession().getFactory() ) ); } return entity; } if ( log.isTraceEnabled() ) ...{ log.trace( "object not resolved in any cache: "+ MessageHelper.infoString( persister, event.getEntityId(), event.getSession().getFactory() ) ); } returnloadFromDatasource(event, persister, keyToLoad, options); }