[hibernate-dev] RE: EntityPersister.initializeLazyProperty: ask for one, initialize all?

Nikita Tovstoles nikita at doppelganger.com
Fri May 22 23:57:07 EDT 2009


Naturally, things are a bit more involved:
-replaced AbstractFieldInterceptor.initializing with a Set tracking that state on a per-fieldName basis.

That wasn't enough - TestLazyExecutable is failing - returning a null value - it almost seems as though the same FilterInterceptor instance is reused by multiple sessions after my awesome coding.

I assumed that at most (or exactly?) one AbstractFieldInterceptor impl instance is created per entity instance per Session and that no fieldInterceptor is used by multiple sessions. 

The interceptor seems to be injected with lazyProps only in PojoEntityTuplizer.afterInitialize() where the following comment resides:

//TODO: if we support multiple fetch groups, we would need
//      to clone the set of lazy properties!
FieldInterceptionHelper.injectFieldInterceptor( entity, getEntityName(), lazyProps, session );


Why is cloning needed? Is it because my assumption about the lifespan of one is incorrect? Is a new FieldInterceptor created every time a different lazy property is accessed for the first time on the same entity?

Thanks

-nikita




-----Original Message-----

Our app fails to scale sufficiently and I'd traced our problems to eager loading of all OneToOne relations when any single one is accessed. I would like to fix that but wanted to get feedback first. I'm referring to Hibernate Core 3.3.1.GA below:

Currently in AbstractFieldInterceptor.intercept():
"uninitializedFields = null; //let's assume that there is only one lazy fetch group, for now!"

proposed fix: 
-after 'result' is returned call uninitializedFields.remove(fieldname). Question: should this only be done if result != null?

And then AbstractEntityPersister.initializeLazyProperties() calls methods that initialize *all* properties even though a specific fieldname is supplied:
* initializeLazyPropertiesFromDatastore or
* initializeLazyPropertiesFromCache

Proposed fix:
-In both cases, determine appropriate 'j' value by searching lazyPropertyNames for 'fieldName'
-only call nullSafeGet, and initializeLazyProperty( fieldName, entity, session, snapshot, j, propValue ) once.


What do folks think?

Thanks,
-nikita


_______________________________________________
hibernate-dev mailing list
hibernate-dev at lists.jboss.org
https://lists.jboss.org/mailman/listinfo/hibernate-dev




More information about the hibernate-dev mailing list