Java Mailing List Archive

http://www.gg3721.com/

Home » the NHibernate development list »

[NHibernate-development] Retrieve subclass from 2nd Level cache

Jesse Napier

2008-09-10

Replies: Find Java Web Hosting

Author LoginPost Reply

I noticed today that subclasses that follow the table per class hierarchy inheritance model are not being returned after they are retrieved from the second level cache if you request the base type.  I did some digging and found that this was the intended action according to the code to get around the problem reported in NH-295. I would create a patch for this but I don’t understand what problem the workaround for NH-295 is supposed to be fixing in this particular instance.

 

Fabio was the one to make this change on June 5th so maybe you can enlighten me on what you were trying to accomplish.  The class in question is DefaultLoadEventListener. Starting on line 415 we have this code

 

CacheEntry entry = (CacheEntry) persister.CacheEntryStructure.Destructure(ce, factory);

 

// Entity was found in second-level cache...

// NH: Different behavior (take a look to options.ExactPersister (NH-295))

if (!options.ExactPersister || entry.Subclass.Equals(persister.EntityName)){

return AssembleCacheEntry(entry, @event.EntityId, persister, @event);

}

 

 

Event though the cache entry was found, the If block causes the cache entry to not be assembled for a subclass and the listener will just return null. If you request a subclass as the base type, this will never pass and cache entries will never be assembled. I don’t understand why we don’t want to return the cache entry when requesting the base type. It’s not possible for a subclass to have the same id as another subclass is it?  

 

Thanks for any info regarding this because it is having some very undesirable effects.

 

Thanks,

Jesse

 

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Nhibernate-development mailing list
Nhibernate-development@(protected)
https://lists.sourceforge.net/lists/listinfo/nhibernate-development
©2008 gg3721.com - Jax Systems, LLC, U.S.A.