Retrieve subclass from 2nd Level cache

"Jesse Napier" <[email protected]> Tue, 9 Sep 2008 22:54:16 -0700
Newsgroups gmane.comp.windows.dotnet.nhibernate.devel
Message-ID <ADDDC70391998C4887386EB544F2600202C32334@gfexchange01.gfhome.gamefly.com>
This is a multi-part message in MIME format.

--===============1465303653==
Content-class: urn:content-classes:message
Content-Type: multipart/alternative;
	boundary="----_=_NextPart_001_01C91309.A932ECE5"

This is a multi-part message in MIME format.

------_=_NextPart_001_01C91309.A932ECE5
Content-Type: text/plain;
	charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

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.

=20

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

=20

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

=20

// 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);

}

=20

=20

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? =20

=20

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

=20

Thanks,

Jesse

=20


------_=_NextPart_001_01C91309.A932ECE5
Content-Type: text/html;
	charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

<html xmlns:v=3D"urn:schemas-microsoft-com:vml" =
xmlns:o=3D"urn:schemas-microsoft-com:office:office" =
xmlns:w=3D"urn:schemas-microsoft-com:office:word" =
xmlns=3D"http://www.w3.org/TR/REC-html40">

<head>
<meta http-equiv=3DContent-Type content=3D"text/html; =
charset=3Dus-ascii">
<meta name=3DGenerator content=3D"Microsoft Word 11 (filtered medium)">
<style>
<!--
 /* Font Definitions */
 @font-face
	{font-family:Verdana;
	panose-1:2 11 6 4 3 5 4 4 2 4;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
	{margin:0in;
	margin-bottom:.0001pt;
	font-size:12.0pt;
	font-family:"Times New Roman";}
a:link, span.MsoHyperlink
	{color:blue;
	text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
	{color:purple;
	text-decoration:underline;}
span.EmailStyle17
	{mso-style-type:personal-compose;
	font-family:Arial;
	color:windowtext;}
@page Section1
	{size:8.5in 11.0in;
	margin:1.0in 1.25in 1.0in 1.25in;}
div.Section1
	{page:Section1;}
-->
</style>

</head>

<body lang=3DEN-US link=3Dblue vlink=3Dpurple>

<div class=3DSection1>

<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'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&#8217;t understand what problem the workaround for NH-295 is =
supposed
to be fixing in this particular instance.<o:p></o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial'><o:p>&nbsp;</o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'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<o:p></o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial'><o:p>&nbsp;</o:p></span></font></p>

<p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D2 =
face=3DVerdana><span
style=3D'font-size:10.0pt;font-family:Verdana'>CacheEntry entry =3D =
(CacheEntry) persister.CacheEntryStructure.Destructure(ce,
factory);<o:p></o:p></span></font></p>

<p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D2 =
color=3D"#dcdccd"
face=3DVerdana><span =
style=3D'font-size:10.0pt;font-family:Verdana;color:#DCDCCD'><o:p>&nbsp;<=
/o:p></span></font></p>

<p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D2 =
color=3Dgreen
face=3DVerdana><span =
style=3D'font-size:10.0pt;font-family:Verdana;color:green'>//
Entity was found in second-level cache...<o:p></o:p></span></font></p>

<p class=3DMsoNormal style=3D'text-autospace:none'><font size=3D2 =
color=3Dgreen
face=3DVerdana><span =
style=3D'font-size:10.0pt;font-family:Verdana;color:green'>//
NH: Different behavior (take a look to options.ExactPersister =
(NH-295))<o:p></o:p></span></font></p>

<p class=3DMsoNormal style=3D'text-autospace:none'><b><font size=3D2 =
face=3DVerdana><span
style=3D'font-size:10.0pt;font-family:Verdana;font-weight:bold'>if</span>=
</font></b><font
size=3D2 face=3DVerdana><span =
style=3D'font-size:10.0pt;font-family:Verdana'> (!options.ExactPersister
|| =
entry.Subclass.Equals(persister.EntityName)){<o:p></o:p></span></font></p=
>

<p class=3DMsoNormal =
style=3D'text-indent:.5in;text-autospace:none'><b><font
size=3D2 face=3DVerdana><span =
style=3D'font-size:10.0pt;font-family:Verdana;
font-weight:bold'>return</span></font></b><font size=3D2 =
face=3DVerdana><span
style=3D'font-size:10.0pt;font-family:Verdana'> =
AssembleCacheEntry(entry, @event.EntityId,
persister, @event);<o:p></o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 face=3DVerdana><span =
style=3D'font-size:10.0pt;
font-family:Verdana'>}</span></font><font size=3D2 face=3DArial><span
style=3D'font-size:10.0pt;font-family:Arial'><o:p></o:p></span></font></p=
>

<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial'><o:p>&nbsp;</o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial'><o:p>&nbsp;</o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial'>Event though the cache entry was found, the <b><span
style=3D'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&#8217;t understand why we don&#8217;t want to return =
the
cache entry when requesting the base type. It&#8217;s not possible for a
subclass to have the same id as another subclass is it? =
&nbsp;<o:p></o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial'><o:p>&nbsp;</o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial'>Thanks for any info regarding this because it is =
having some
very undesirable effects.<o:p></o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial'><o:p>&nbsp;</o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial'>Thanks,<o:p></o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial'>Jesse<o:p></o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial'><o:p>&nbsp;</o:p></span></font></p>

</div>

</body>

</html>

------_=_NextPart_001_01C91309.A932ECE5--


--===============1465303653==
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=/
--===============1465303653==
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

--===============1465303653==--