Re: Retrieve subclass from 2nd Level cache
"Jesse Napier" <[email protected]> Wed, 10 Sep 2008 10:35:16 -0700
| Newsgroups | gmane.comp.windows.dotnet.nhibernate.devel |
|---|---|
| Message-ID | <ADDDC70391998C4887386EB544F2600202C3236F@gfexchange01.gfhome.gamefly.com> |
This is a multi-part message in MIME format. --===============0841977118== Content-class: urn:content-classes:message Content-Type: multipart/alternative; boundary="----_=_NextPart_001_01C9136B.96E84874" This is a multi-part message in MIME format. ------_=_NextPart_001_01C9136B.96E84874 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hi Fabio, The problem is, I don't know how to create test that could verify an item was retrieved from the second level cache and not the database. Do you have any ideas? =20 Jesse =20 ________________________________ From: [email protected] [mailto:[email protected]] On Behalf Of Fabio Maulo Sent: Tuesday, September 09, 2008 11:18 PM To: the NHibernate development list Subject: Re: [NHibernate-development] Retrieve subclass from 2nd Level cache =20 Please create a JIRA ticket with a testCase using the style of NHibernate.Test.NHSpecificTest Thanks. 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. =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 ------------------------------------------------------------------------ - 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=3D100&url=3D/ _______________________________________________ Nhibernate-development mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/nhibernate-development --=20 Fabio Maulo ------_=_NextPart_001_01C9136B.96E84874 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:st1=3D"urn:schemas-microsoft-com:office:smarttags" = xmlns=3D"http://www.w3.org/TR/REC-html40"> <head> <META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; = charset=3Dus-ascii"> <meta name=3DGenerator content=3D"Microsoft Word 11 (filtered medium)"> <!--[if !mso]> <style> v\:* {behavior:url(#default#VML);} o\:* {behavior:url(#default#VML);} w\:* {behavior:url(#default#VML);} .shape {behavior:url(#default#VML);} </style> <![endif]--><o:SmartTagType namespaceuri=3D"urn:schemas-microsoft-com:office:smarttags" = name=3D"PersonName"/> <!--[if !mso]> <style> st1\:*{behavior:url(#default#ieooui) } </style> <![endif]--> <style> <!-- /* Font Definitions */ @font-face {font-family:Tahoma; panose-1:2 11 6 4 3 5 4 4 2 4;} @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:blue; text-decoration:underline;} p {mso-margin-top-alt:auto; margin-right:0in; mso-margin-bottom-alt:auto; margin-left:0in; font-size:12.0pt; font-family:"Times New Roman";} span.EmailStyle18 {mso-style-type:personal-reply; font-family:Arial; color:navy;} @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=3Dblue> <div class=3DSection1> <p class=3DMsoNormal><font size=3D2 color=3Dnavy face=3DArial><span = style=3D'font-size: 10.0pt;font-family:Arial;color:navy'>Hi = Fabio,<o:p></o:p></span></font></p> <p class=3DMsoNormal><font size=3D2 color=3Dnavy face=3DArial><span = style=3D'font-size: 10.0pt;font-family:Arial;color:navy'>The problem is, I don’t know = how to create test that could verify an item was retrieved from the second = level cache and not the database. Do you have any = ideas?<o:p></o:p></span></font></p> <p class=3DMsoNormal><font size=3D2 color=3Dnavy face=3DArial><span = style=3D'font-size: 10.0pt;font-family:Arial;color:navy'><o:p> </o:p></span></font></p> <p class=3DMsoNormal><font size=3D2 color=3Dnavy face=3DArial><span = style=3D'font-size: 10.0pt;font-family:Arial;color:navy'>Jesse<o:p></o:p></span></font></p> <p class=3DMsoNormal><font size=3D2 color=3Dnavy face=3DArial><span = style=3D'font-size: 10.0pt;font-family:Arial;color:navy'><o:p> </o:p></span></font></p> <div> <div class=3DMsoNormal align=3Dcenter style=3D'text-align:center'><font = size=3D3 face=3D"Times New Roman"><span style=3D'font-size:12.0pt'> <hr size=3D2 width=3D"100%" align=3Dcenter tabindex=3D-1> </span></font></div> <p class=3DMsoNormal><b><font size=3D2 face=3DTahoma><span = style=3D'font-size:10.0pt; font-family:Tahoma;font-weight:bold'>From:</span></font></b><font = size=3D2 face=3DTahoma><span style=3D'font-size:10.0pt;font-family:Tahoma'> [email protected] [mailto:[email protected]] <b><span style=3D'font-weight:bold'>On Behalf Of </span></b>Fabio Maulo<br> <b><span style=3D'font-weight:bold'>Sent:</span></b> Tuesday, September = 09, 2008 11:18 PM<br> <b><span style=3D'font-weight:bold'>To:</span></b> <st1:PersonName = w:st=3D"on">the NHibernate development list</st1:PersonName><br> <b><span style=3D'font-weight:bold'>Subject:</span></b> Re: [NHibernate-development] Retrieve subclass from 2nd Level = cache</span></font><o:p></o:p></p> </div> <p class=3DMsoNormal><font size=3D3 face=3D"Times New Roman"><span = style=3D'font-size: 12.0pt'><o:p> </o:p></span></font></p> <div> <p class=3DMsoNormal><font size=3D3 face=3D"Times New Roman"><span = style=3D'font-size: 12.0pt'>Please create a JIRA ticket with a testCase using the style of NHibernate.Test.NHSpecificTest<o:p></o:p></span></font></p> <div> <p class=3DMsoNormal style=3D'margin-bottom:12.0pt'><font size=3D3 face=3D"Times New Roman"><span = style=3D'font-size:12.0pt'>Thanks.<o:p></o:p></span></font></p> <div> <p class=3DMsoNormal><font size=3D3 face=3D"Times New Roman"><span = style=3D'font-size: 12.0pt'>2008/9/10 Jesse Napier <<a = href=3D"mailto:[email protected]">[email protected]</a>><o:p></o:p= ></span></font></p> <div link=3Dblue vlink=3Dpurple> <div> <p><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. 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><o:p></o:p></p> <p><font size=3D2 face=3DArial><span = style=3D'font-size:10.0pt;font-family:Arial'> </span></font><o:p></o= :p></p> <p><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. The class in = question is DefaultLoadEventListener. Starting on line 415 we have this = code</span></font><o:p></o:p></p> <p><font size=3D2 face=3DArial><span = style=3D'font-size:10.0pt;font-family:Arial'> </span></font><o:p></o= :p></p> <p 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);</span></font><o:p></o:p></p> <p 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'> </span= ></font><o:p></o:p></p> <p 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...</span></font><o:p></o:p></p> <p 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))</span></font><o:p></o:p></p> <p 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)){</span></font><o:p></o:p></p= > <p 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</s= pan></font></b><font size=3D2 face=3DVerdana><span = style=3D'font-size:10.0pt;font-family:Verdana'> AssembleCacheEntry(entry, @event.EntityId, persister, = @event);</span></font><o:p></o:p></p> <p><font size=3D2 face=3DVerdana><span = style=3D'font-size:10.0pt;font-family:Verdana'>}</span></font><o:p></o:p>= </p> <p><font size=3D2 face=3DArial><span = style=3D'font-size:10.0pt;font-family:Arial'> </span></font><o:p></o= :p></p> <p><font size=3D2 face=3DArial><span = style=3D'font-size:10.0pt;font-family:Arial'> </span></font><o:p></o= :p></p> <p><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'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? </span></font><o:p></o:p></p> <p><font size=3D2 face=3DArial><span = style=3D'font-size:10.0pt;font-family:Arial'> </span></font><o:p></o= :p></p> <p><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.</span></font><o:p></o:p></p> <p><font size=3D2 face=3DArial><span = style=3D'font-size:10.0pt;font-family:Arial'> </span></font><o:p></o= :p></p> <p><font size=3D2 face=3DArial><span = style=3D'font-size:10.0pt;font-family:Arial'>Thanks,</span></font><o:p></= o:p></p> <p><font size=3D2 face=3DArial><span = style=3D'font-size:10.0pt;font-family:Arial'>Jesse</span></font><o:p></o:= p></p> <p><font size=3D2 face=3DArial><span = style=3D'font-size:10.0pt;font-family:Arial'> </span></font><o:p></o= :p></p> </div> </div> <p class=3DMsoNormal style=3D'margin-bottom:12.0pt'><font size=3D3 face=3D"Times New Roman"><span style=3D'font-size:12.0pt'><br> -------------------------------------------------------------------------= <br> This SF.Net email is sponsored by the Moblin Your Move Developer's = challenge<br> Build the coolest Linux based applications with Moblin SDK & win = great prizes<br> Grand prize is a trip for two to an Open Source event anywhere in the = world<br> <a = href=3D"http://moblin-contest.org/redirect.php?banner_id=3D100&url=3D= /" target=3D"_blank">http://moblin-contest.org/redirect.php?banner_id=3D100&= amp;url=3D/</a><br> _______________________________________________<br> Nhibernate-development mailing list<br> <a = href=3D"mailto:[email protected]">Nhibernate-d= [email protected]</a><br> <a = href=3D"https://lists.sourceforge.net/lists/listinfo/nhibernate-developme= nt" target=3D"_blank">https://lists.sourceforge.net/lists/listinfo/nhibernate= -development</a><o:p></o:p></span></font></p> </div> <p class=3DMsoNormal><font size=3D3 face=3D"Times New Roman"><span = style=3D'font-size: 12.0pt'><br> <br clear=3Dall> <br> -- <br> Fabio Maulo<o:p></o:p></span></font></p> </div> </div> </div> </body> </html> ------_=_NextPart_001_01C9136B.96E84874-- --===============0841977118== 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=/ --===============0841977118== 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 --===============0841977118==--