views:

483

answers:

1

Im mainly looking at the EntityStatics (http://www.hibernate.org/hib_docs/v3/api/org/hibernate/stat/EntityStatistics.html). I can see a lot of fetch, loads and updates and i cant find anywhere that says what the difference between them are.

+2  A: 

Working backward through the code, the fetch counter only gets incremented when the entity is retrieved from the datasource (as opposed to any caches) -

    protected Object loadFromDatasource(
  final LoadEvent event,
  final EntityPersister persister,
  final EntityKey keyToLoad,
  final LoadEventListener.LoadType options) {
 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;
}

The load counter was called from too many places to track them all down, but it looks like it gets incremented any time the entity gets loaded, whether from the datasource or the caches.

Alex Zuroff
Update? I seem to be getting lots of updates on entities that are immutable.
Sam