Re: Retrieve subclass from 2nd Level cache
"Ayende Rahien" <[email protected]> Wed, 10 Sep 2008 20:50:40 +0300
| Newsgroups | gmane.comp.windows.dotnet.nhibernate.devel |
|---|---|
| Message-ID | <[email protected]> |
--===============1205856929== Content-Type: multipart/alternative; boundary="----=_Part_24575_14988145.1221069040420" ------=_Part_24575_14988145.1221069040420 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Delete it from the DB directly, see if it is returned from the cache. On Wed, Sep 10, 2008 at 8:35 PM, Jesse Napier <[email protected]> wrote: > 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? > > > > Jesse > > > ------------------------------ > > *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 > > > > 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. > > > > 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 > > ------------------------------------------------------------------------- > 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 > > ------=_Part_24575_14988145.1221069040420 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline <div dir="ltr">Delete it from the DB directly, see if it is returned from the cache.<br><br><div class="gmail_quote">On Wed, Sep 10, 2008 at 8:35 PM, Jesse Napier <span dir="ltr"><<a href="mailto:[email protected]">[email protected]</a>></span> wrote:<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="blue"> <div> <p><font size="2" color="navy" face="Arial"><span style="font-size:10.0pt;font-family:Arial;color:navy">Hi Fabio,</span></font></p> <p><font size="2" color="navy" face="Arial"><span style="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?</span></font></p> <p><font size="2" color="navy" face="Arial"><span style="font-size:10.0pt;font-family:Arial;color:navy"> </span></font></p> <p><font size="2" color="navy" face="Arial"><span style="font-size:10.0pt;font-family:Arial;color:navy">Jesse</span></font></p> <p><font size="2" color="navy" face="Arial"><span style="font-size:10.0pt;font-family:Arial;color:navy"> </span></font></p> <div> <div align="center" style="text-align:center"><font size="3" face="Times New Roman"><span style="font-size:12.0pt"> <hr size="2" width="100%" align="center"> </span></font></div> <p><b><font size="2" face="Tahoma"><span style="font-size:10.0pt;font-family:Tahoma;font-weight:bold">From:</span></font></b><font size="2" face="Tahoma"><span style="font-size:10.0pt;font-family:Tahoma"> <a href="mailto:[email protected]" target="_blank">[email protected]</a> [mailto:<a href="mailto:[email protected]" target="_blank">[email protected]</a>] <b><span style="font-weight:bold">On Behalf Of </span></b>Fabio Maulo<br> <b><span style="font-weight:bold">Sent:</span></b> Tuesday, September 09, 2008 11:18 PM<br> <b><span style="font-weight:bold">To:</span></b> the NHibernate development list<br> <b><span style="font-weight:bold">Subject:</span></b> Re: [NHibernate-development] Retrieve subclass from 2nd Level cache</span></font></p> </div><div><div></div><div class="Wj3C7c"> <p><font size="3" face="Times New Roman"><span style="font-size:12.0pt"> </span></font></p> <div> <p><font size="3" face="Times New Roman"><span style="font-size:12.0pt">Please create a JIRA ticket with a testCase using the style of NHibernate.Test.NHSpecificTest</span></font></p> <div> <p style="margin-bottom:12.0pt"><font size="3" face="Times New Roman"><span style="font-size:12.0pt">Thanks.</span></font></p> <div> <p><font size="3" face="Times New Roman"><span style="font-size:12.0pt">2008/9/10 Jesse Napier <<a href="mailto:[email protected]" target="_blank">[email protected]</a>></span></font></p> <div 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. 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"> </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. 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"> </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"> </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></p> <p><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"> </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? </span></font></p> <p><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">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"> </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"> </span></font></p> </div> </div> <p style="margin-bottom:12.0pt"><font size="3" face="Times New Roman"><span style="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="http://moblin-contest.org/redirect.php?banner_id=100&url=/" target="_blank">http://moblin-contest.org/redirect.php?banner_id=100&url=/</a><br> _______________________________________________<br> Nhibernate-development mailing list<br> <a href="mailto:[email protected]" target="_blank">[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></span></font></p> </div> <p><font size="3" face="Times New Roman"><span style="font-size:12.0pt"><br> <br clear="all"> <br> -- <br> Fabio Maulo</span></font></p> </div> </div> </div></div></div> </div> <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="http://moblin-contest.org/redirect.php?banner_id=100&url=/" target="_blank">http://moblin-contest.org/redirect.php?banner_id=100&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></div> ------=_Part_24575_14988145.1221069040420-- --===============1205856929== 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=/ --===============1205856929== 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 --===============1205856929==--