Re: Retrieve subclass from 2nd Level cache

"Fabio Maulo" <[email protected]> Wed, 10 Sep 2008 03:18:24 -0300
Newsgroups gmane.comp.windows.dotnet.nhibernate.devel
Message-ID <[email protected]>
--===============1607803077==
Content-Type: multipart/alternative; 
	boundary="----=_Part_1180_7622497.1221027504475"

------=_Part_1180_7622497.1221027504475
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

Please create a JIRA ticket with a testCase using the style
of NHibernate.Test.NHSpecificTestThanks.

2008/9/10 Jesse Napier <[email protected]>

>  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
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/nhibernate-development
>
>


-- 
Fabio Maulo

------=_Part_1180_7622497.1221027504475
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

<div dir="ltr">Please create a JIRA ticket with a testCase using the style of&nbsp;NHibernate.Test.NHSpecificTest<div>Thanks.<br><br><div class="gmail_quote">2008/9/10 Jesse Napier <span dir="ltr">&lt;<a href="mailto:[email protected]">[email protected]</a>&gt;</span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">








<div lang="EN-US" link="blue" vlink="purple">

<div>

<p><font size="2" face="Arial"><span style="font-size:10.0pt;font-family:Arial">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.&nbsp; 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.</span></font></p>

<p><font size="2" face="Arial"><span style="font-size:10.0pt;font-family:Arial">&nbsp;</span></font></p>

<p><font size="2" face="Arial"><span style="font-size:10.0pt;font-family:Arial">Fabio was the one to make this change on June 5<sup>th</sup>
so maybe you can enlighten me on what you were trying to accomplish. &nbsp;The
class in question is DefaultLoadEventListener. Starting on line 415 we have
this code</span></font></p>

<p><font size="2" face="Arial"><span style="font-size:10.0pt;font-family:Arial">&nbsp;</span></font></p>

<p style="text-autospace:none"><font size="2" face="Verdana"><span style="font-size:10.0pt;font-family:Verdana">CacheEntry entry = (CacheEntry) persister.CacheEntryStructure.Destructure(ce,
factory);</span></font></p>

<p style="text-autospace:none"><font size="2" color="#dcdccd" face="Verdana"><span style="font-size:10.0pt;font-family:Verdana;color:#DCDCCD">&nbsp;</span></font></p>

<p style="text-autospace:none"><font size="2" color="green" face="Verdana"><span style="font-size:10.0pt;font-family:Verdana;color:green">//
Entity was found in second-level cache...</span></font></p>

<p style="text-autospace:none"><font size="2" color="green" face="Verdana"><span style="font-size:10.0pt;font-family:Verdana;color:green">//
NH: Different behavior (take a look to options.ExactPersister (NH-295))</span></font></p>

<p style="text-autospace:none"><b><font size="2" face="Verdana"><span style="font-size:10.0pt;font-family:Verdana;font-weight:bold">if</span></font></b><font size="2" face="Verdana"><span style="font-size:10.0pt;font-family:Verdana"> (!options.ExactPersister
|| entry.Subclass.Equals(persister.EntityName)){</span></font></p>

<p style="text-indent:.5in;text-autospace:none"><b><font size="2" face="Verdana"><span style="font-size:10.0pt;font-family:Verdana;font-weight:bold">return</span></font></b><font size="2" face="Verdana"><span style="font-size:10.0pt;font-family:Verdana"> AssembleCacheEntry(entry, @event.EntityId,
persister, @event);</span></font></p>

<p><font size="2" face="Verdana"><span style="font-size:10.0pt;font-family:Verdana">}</span></font><font size="2" face="Arial"><span style="font-size:10.0pt;font-family:Arial"></span></font></p>

<p><font size="2" face="Arial"><span style="font-size:10.0pt;font-family:Arial">&nbsp;</span></font></p>

<p><font size="2" face="Arial"><span style="font-size:10.0pt;font-family:Arial">&nbsp;</span></font></p>

<p><font size="2" face="Arial"><span style="font-size:10.0pt;font-family:Arial">Event though the cache entry was found, the <b><span style="font-weight:bold">If</span></b> 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? &nbsp;</span></font></p>

<p><font size="2" face="Arial"><span style="font-size:10.0pt;font-family:Arial">&nbsp;</span></font></p>

<p><font size="2" face="Arial"><span style="font-size:10.0pt;font-family:Arial">Thanks for any info regarding this because it is having some
very undesirable effects.</span></font></p>

<p><font size="2" face="Arial"><span style="font-size:10.0pt;font-family:Arial">&nbsp;</span></font></p>

<p><font size="2" face="Arial"><span style="font-size:10.0pt;font-family:Arial">Thanks,</span></font></p>

<p><font size="2" face="Arial"><span style="font-size:10.0pt;font-family:Arial">Jesse</span></font></p>

<p><font size="2" face="Arial"><span style="font-size:10.0pt;font-family:Arial">&nbsp;</span></font></p>

</div>

</div>


<br>-------------------------------------------------------------------------<br>
This SF.Net email is sponsored by the Moblin Your Move Developer&#39;s challenge<br>
Build the coolest Linux based applications with Moblin SDK &amp; win great prizes<br>
Grand prize is a trip for two to an Open Source event anywhere in the world<br>
<a href="http://moblin-contest.org/redirect.php?banner_id=100&amp;url=/" target="_blank">http://moblin-contest.org/redirect.php?banner_id=100&amp;url=/</a><br>_______________________________________________<br>
Nhibernate-development mailing list<br>
<a href="mailto:[email protected]">[email protected]</a><br>
<a href="https://lists.sourceforge.net/lists/listinfo/nhibernate-development" target="_blank">https://lists.sourceforge.net/lists/listinfo/nhibernate-development</a><br>
<br></blockquote></div><br><br clear="all"><br>-- <br>Fabio Maulo<br>
</div></div>

------=_Part_1180_7622497.1221027504475--


--===============1607803077==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

-------------------------------------------------------------------------
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=/
--===============1607803077==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
Nhibernate-development mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/nhibernate-development

--===============1607803077==--