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