Fwd: [nhusers] Re: Is NHibernate.Caches.SysCache working?

"James Kovacs" <[email protected]> Tue, 9 Sep 2008 10:35:25 -0600
Newsgroups gmane.comp.windows.dotnet.nhibernate.devel
Message-ID <[email protected]>
--===============0590902211==
Content-Type: multipart/alternative; 
	boundary="----=_Part_56483_6801918.1220978125394"

------=_Part_56483_6801918.1220978125394
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

Meant to send this to NHDev for discussion. See message below...
James
--
James Kovacs, B.Sc., M.Sc., MCSD, MCT
Microsoft MVP - C# Architecture
http://www.jameskovacs.com
[email protected]
403-397-3177 (mobile)


---------- Forwarded message ----------
From: James Kovacs <[email protected]>
Date: Tue, Sep 9, 2008 at 10:01 AM
Subject: Re: [nhusers] Re: Is NHibernate.Caches.SysCache working?
To: [email protected]


Can we do anything in the code to make this error more obvious? Is there a
reason that we can't throw an exception if we try to load/save entities
outside a transaction given that it is required - and changed behaviour from
1.X? I would think that you could throw on a load/get/query outside of a tx
and throw if Save/Update/SaveOrUpdate is called without a tx present, though
I haven't looked at the code.
James
--
James Kovacs, B.Sc., M.Sc., MCSD, MCT
Microsoft MVP - C# Architecture
http://www.jameskovacs.com
[email protected]
403-397-3177 (mobile)


On Tue, Sep 9, 2008 at 9:02 AM, Craig Neuwirt <[email protected]> wrote:

> Absolutely.... :-)
>
>
> On Tue, Sep 9, 2008 at 10:00 AM, Ayende Rahien <[email protected]> wrote:
>
>> Can I expect a blog post out of this?
>>
>>
>> On Tue, Sep 9, 2008 at 5:56 PM, Craig Neuwirt <[email protected]> wrote:
>>
>>> James,
>>>
>>> Thanks for assisting me on this issue.  The problem, as you pointed out
>>> all along, had to do with performing a save without a tx.  It polluted the
>>> second level cache so I wasn't testing with the environment I was expecting.
>>>
>>> Cheers,
>>>  craig
>>>
>>>
>>> On Mon, Sep 8, 2008 at 10:39 PM, James Kovacs <[email protected]>wrote:
>>>
>>>> In order for the entity to be saved, you need to commit the tx. In the
>>>> test, you should probably purge the 2nd level cache by evicting the
>>>> serialized entity.
>>>> sessionFactory.Evict(typeof(Foo));
>>>>
>>>> will remove all serialized Foo objects from the 2nd level cache. To
>>>> evict only one:
>>>>
>>>> sessionFactory.Evict(typeof(Foo), id);
>>>>
>>>> James
>>>> --
>>>> James Kovacs, B.Sc., M.Sc., MCSD, MCT
>>>> Microsoft MVP - C# Architecture
>>>> http://www.jameskovacs.com
>>>> [email protected]
>>>> 403-397-3177 (mobile)
>>>>
>>>>
>>>> On Mon, Sep 8, 2008 at 6:04 PM, Craig Neuwirt <[email protected]>wrote:
>>>>
>>>>> Ayende,
>>>>>
>>>>>   Thanks for the feedback.  However, I believe the Saving operation is
>>>>> polluting the test.  I want my test to demonstrate the ability to execute a
>>>>> query against EXISTING data in the database and have that query put in the
>>>>> query cache so that the next time I execute the same query, it uses the
>>>>> cache instead of hitting the db.
>>>>>
>>>>> So to test this, a Foo needs to be in the db and this part needs to be
>>>>> removed
>>>>>  using (ISession s = OpenSession())
>>>>>     using (ITransaction tx = s.BeginTransaction())
>>>>>     {
>>>>>         s.Save(foo);
>>>>>         tx.Commit();
>>>>>     }
>>>>> Isn't this the normal way of using the query cache?
>>>>>
>>>>> thanks.
>>>>>  craig
>>>>> On Mon, Sep 8, 2008 at 3:07 PM, Ayende Rahien <[email protected]>wrote:
>>>>>
>>>>>> Blah!
>>>>>> We were looking at the wrong spot all along.
>>>>>> This test works, I marked the parts that I had to change.
>>>>>>
>>>>>> Perfectly obvious, when you think of this.
>>>>>> You asked NHibernate to create new foo, so it has to put it in the
>>>>>> cache and invalidate all Foos until the transaction is commited.
>>>>>> It does so by specifying a timeout value of one minute from now
>>>>>> (IIRC), which obivously mixes up with the test timing.
>>>>>>
>>>>>> When the tx is commited, NH can make this visible again, and set it to
>>>>>> the current timestamp.
>>>>>>
>>>>>>
>>>>>> [Test]
>>>>>> public void DoesNotLoadEntityFromSysCache()
>>>>>> {
>>>>>>     Foo foo = new Foo();
>>>>>>     foo.Name = "Craig";
>>>>>>
>>>>>>     using (ISession s = OpenSession())
>>>>>>     using (ITransaction tx = s.BeginTransaction())
>>>>>>     {
>>>>>>         s.Save(foo);
>>>>>>         tx.Commit();
>>>>>>     }
>>>>>>
>>>>>>     using (ISession s = OpenSession())
>>>>>>     using( ITransaction tx = s.BeginTransaction())
>>>>>>     {
>>>>>>         Foo result = (Foo)s.CreateCriteria(typeof(Foo))
>>>>>>             .Add(Property.ForName("Name").Eq("Craig"))
>>>>>>             .SetCacheable(true)
>>>>>>             .UniqueResult();
>>>>>>
>>>>>>         Assert.IsNotNull(result);
>>>>>>         tx.Commit();
>>>>>>     }
>>>>>>
>>>>>>     using (ISession s = OpenSession())
>>>>>>     {
>>>>>>         using (IDbCommand command = s.Connection.CreateCommand())
>>>>>>         {
>>>>>>             command.CommandText = "DELETE FROM Foos";
>>>>>>             command.ExecuteNonQuery();
>>>>>>         }
>>>>>>     }
>>>>>>
>>>>>>     using (ISession s = OpenSession())
>>>>>>     using (ITransaction tx = s.BeginTransaction())
>>>>>>     {
>>>>>>         Foo result = (Foo)s.CreateCriteria(typeof(Foo))
>>>>>>             .Add(Property.ForName("Name").Eq("Craig"))
>>>>>>             .SetCacheable(true)
>>>>>>             .UniqueResult();
>>>>>>
>>>>>>         Assert.IsNotNull(result);
>>>>>>
>>>>>>         tx.Commit();
>>>>>>     }
>>>>>>
>>>>>>     using (ISession s = OpenSession())
>>>>>>     using (ITransaction tx = s.BeginTransaction())
>>>>>>     {
>>>>>>         s.Delete("from Foo");
>>>>>>         s.Flush();
>>>>>>
>>>>>>         tx.Commit();
>>>>>>
>>>>>>     }
>>>>>> }
>>>>>>
>>>>>> On Mon, Sep 8, 2008 at 10:47 PM, Craig Neuwirt <[email protected]>wrote:
>>>>>>
>>>>>>> Yeah, that's what I eluded to on my first post.
>>>>>>>
>>>>>>> Thanks for letting me know I am not completely crazy yet ;-)
>>>>>>>
>>>>>>>
>>>>>>> On Mon, Sep 8, 2008 at 1:28 PM, Ayende Rahien <[email protected]>wrote:
>>>>>>>
>>>>>>>> I think there is still something funny going on, looks to be related
>>>>>>>> to the time stamps that were going on there.
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> On Mon, Sep 8, 2008 at 9:20 PM, James Kovacs <
>>>>>>>> [email protected]> wrote:
>>>>>>>>
>>>>>>>>> I modified your patch to use transactions and SysCache worked for
>>>>>>>>> me as expected. I even debugged through and looked at the contents of the
>>>>>>>>> Foos table to verify that the IDbCommand did in fact delete the row. I've
>>>>>>>>> since reverted the code, but can re-create it tonight when I get home.
>>>>>>>>>  James
>>>>>>>>> --
>>>>>>>>> James Kovacs, B.Sc., M.Sc., MCSD, MCT
>>>>>>>>> Microsoft MVP - C# Architecture
>>>>>>>>> http://www.jameskovacs.com
>>>>>>>>> [email protected]
>>>>>>>>> 403-397-3177 (mobile)
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>   On Mon, Sep 8, 2008 at 12:16 PM, Craig Neuwirt <
>>>>>>>>> [email protected]> wrote:
>>>>>>>>>
>>>>>>>>>> So, was their actually a determination made whether or not
>>>>>>>>>> SysCache is working as expected or there is actually a problem.  If it is
>>>>>>>>>> the former, can someone please show me how to make it work (you can make
>>>>>>>>>> updates the patch I submitted)
>>>>>>>>>>
>>>>>>>>>> thanks,
>>>>>>>>>>   craig
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> On Sun, Sep 7, 2008 at 7:02 PM, Ayende Rahien <[email protected]>wrote:
>>>>>>>>>>
>>>>>>>>>>> You have to commit the transaction.
>>>>>>>>>>> NH requires transactions for reads as well.
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> On Mon, Sep 8, 2008 at 2:53 AM, Craig Neuwirt <
>>>>>>>>>>> [email protected]> wrote:
>>>>>>>>>>>
>>>>>>>>>>>> Hey James,
>>>>>>>>>>>>
>>>>>>>>>>>>   You are absolutely correct.  Once I added the transaction, my
>>>>>>>>>>>> unit test passed.  However, the actual scenario I am trying to get working
>>>>>>>>>>>> is assuming data is in the db already and I perform an initial query.  I
>>>>>>>>>>>> want that result to go into the second level cache so it is retrieved from
>>>>>>>>>>>> the cache when the same query is executed.  How do I make that happen?  I
>>>>>>>>>>>> tried putting transaction around the query, but that didn't work and I don't
>>>>>>>>>>>> think that should be necessary for reads.
>>>>>>>>>>>>
>>>>>>>>>>>> thanks,
>>>>>>>>>>>> craig
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> On Sun, Sep 7, 2008 at 5:14 PM, James Kovacs <
>>>>>>>>>>>> [email protected]> wrote:
>>>>>>>>>>>>
>>>>>>>>>>>>> I am looking at it right now. Initial investigations... The
>>>>>>>>>>>>> problem seems to stem from lack of transaction handling in the test case. If
>>>>>>>>>>>>> rather than flushing the session, you commit a transaction, the SysCache
>>>>>>>>>>>>> returns data appropriately. I'll post more as I find out more. (Just posting
>>>>>>>>>>>>> to save Ayende some time.)
>>>>>>>>>>>>>
>>>>>>>>>>>>> James
>>>>>>>>>>>>> --
>>>>>>>>>>>>> James Kovacs, B.Sc., M.Sc., MCSD, MCT
>>>>>>>>>>>>> Microsoft MVP - C# Architecture
>>>>>>>>>>>>> http://www.jameskovacs.com
>>>>>>>>>>>>> [email protected]
>>>>>>>>>>>>> 403-397-3177 (mobile)
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>> On Sun, Sep 7, 2008 at 4:07 PM, Ayende Rahien <
>>>>>>>>>>>>> [email protected]> wrote:
>>>>>>>>>>>>>
>>>>>>>>>>>>>> Guys,
>>>>>>>>>>>>>> I am going to look at the issue now, will post my results soon
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> On Sun, Sep 7, 2008 at 10:44 PM, Gildas <
>>>>>>>>>>>>>> [email protected]> wrote:
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> Fabio, I know that I'm still noob in NHibernate and that I
>>>>>>>>>>>>>>> may ask
>>>>>>>>>>>>>>> stupid questions. I'm sorry if you are bored with this, but
>>>>>>>>>>>>>>> well,
>>>>>>>>>>>>>>> please understand that I'm just trying to resolve a problem I
>>>>>>>>>>>>>>> did not
>>>>>>>>>>>>>>> have before upgrading to last NHibernate trunk.
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> Going through Rhino code, I can see that my session is
>>>>>>>>>>>>>>> created at each
>>>>>>>>>>>>>>> request, so that's not the problem.
>>>>>>>>>>>>>>> Anyway, I still don't have any second level cache. Items are
>>>>>>>>>>>>>>> updated
>>>>>>>>>>>>>>> but never retrieved from it.
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> Can someone check the test case from craig, which is failing
>>>>>>>>>>>>>>> and don't
>>>>>>>>>>>>>>> use any fancy session management ?
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> Thanks
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> On Sep 7, 8:35 pm, "Fabio Maulo" <[email protected]>
>>>>>>>>>>>>>>> wrote:
>>>>>>>>>>>>>>> > 2008/9/7 Gildas <[email protected]>
>>>>>>>>>>>>>>>  >
>>>>>>>>>>>>>>> >
>>>>>>>>>>>>>>> >
>>>>>>>>>>>>>>> > > So I'm going to ask if this is the right way to handle
>>>>>>>>>>>>>>> sessions ? From
>>>>>>>>>>>>>>> > > what I remember of NHibernate, NH Sessions must not be
>>>>>>>>>>>>>>> stored in
>>>>>>>>>>>>>>> > > HttpContext.Session. I may not understand the reasons why
>>>>>>>>>>>>>>> this done
>>>>>>>>>>>>>>> > > like this in UnitOfWorkApplication, maybe for long
>>>>>>>>>>>>>>> transactions
>>>>>>>>>>>>>>> > > management ?
>>>>>>>>>>>>>>> >
>>>>>>>>>>>>>>> > Rhino UoW use httpSession only for long conversation...
>>>>>>>>>>>>>>> > The NhSession CAN be stored in the httpSession simply
>>>>>>>>>>>>>>> because is the "most
>>>>>>>>>>>>>>> > simple" way to manage long-conversations.
>>>>>>>>>>>>>>> > --
>>>>>>>>>>>>>>> > Fabio Maulo
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>
>>>>>>
>>>>
>>>>
>>>>
>>>
>>>
>>>
>>
>>
>>
>
> --~--~---------~--~----~------------~-------~--~----~
> You received this message because you are subscribed to the Google Groups
> "nhusers" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]<nhusers%[email protected]>
> For more options, visit this group at
> http://groups.google.com/group/nhusers?hl=en
> -~----------~----~----~----~------~----~------~--~---
>
>

------=_Part_56483_6801918.1220978125394
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

<div dir="ltr">Meant to send this to NHDev for discussion. See message below...<div><br></div><div>James<br clear="all">--<br>James Kovacs, B.Sc., M.Sc., MCSD, MCT<br>Microsoft MVP - C# Architecture<br><a href="http://www.jameskovacs.com">http://www.jameskovacs.com</a><br>
<a href="mailto:[email protected]">[email protected]</a><br>403-397-3177 (mobile)<br>
<br><br><div class="gmail_quote">---------- Forwarded message ----------<br>From: <b class="gmail_sendername">James Kovacs</b> <span dir="ltr">&lt;<a href="mailto:[email protected]">[email protected]</a>&gt;</span><br>
Date: Tue, Sep 9, 2008 at 10:01 AM<br>Subject: Re: [nhusers] Re: Is NHibernate.Caches.SysCache working?<br>To: <a href="mailto:[email protected]">[email protected]</a><br><br><br><div dir="ltr">Can we do anything in the code to make this error more obvious? Is there a reason that we can&#39;t throw an exception if we try to load/save entities outside a transaction given that it is required - and changed behaviour from 1.X? I would think that you could throw on a load/get/query outside of a tx and throw if Save/Update/SaveOrUpdate is called without a tx present, though I haven&#39;t looked at the code.<div>

<div><br></div><div><div class="Ih2E3d">James<br clear="all">--<br>James Kovacs, B.Sc., M.Sc., MCSD, MCT<br>Microsoft MVP - C# Architecture<br><a href="http://www.jameskovacs.com" target="_blank">http://www.jameskovacs.com</a><br>
<a href="mailto:[email protected]" target="_blank">[email protected]</a><br>
403-397-3177 (mobile)<br>
<br><br></div><div><div></div><div class="Wj3C7c"><div class="gmail_quote">On Tue, Sep 9, 2008 at 9:02 AM, Craig Neuwirt <span dir="ltr">&lt;<a href="mailto:[email protected]" target="_blank">[email protected]</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr">Absolutely.... :-)<div><div></div><div><br><br><div class="gmail_quote">On Tue, Sep 9, 2008 at 10:00 AM, Ayende Rahien <span dir="ltr">&lt;<a href="mailto:[email protected]" target="_blank">[email protected]</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="border-left:1px solid rgb(204, 204, 204);margin:0pt 0pt 0pt 0.8ex;padding-left:1ex">
<div dir="ltr">Can I expect a blog post out of this?<div><div></div><div><br><br><div class="gmail_quote">On Tue, Sep 9, 2008 at 5:56 PM, Craig Neuwirt <span dir="ltr">&lt;<a href="mailto:[email protected]" target="_blank">[email protected]</a>&gt;</span> wrote:<br>



<blockquote class="gmail_quote" style="border-left:1px solid rgb(204, 204, 204);margin:0pt 0pt 0pt 0.8ex;padding-left:1ex"><div dir="ltr">James, <br><br>Thanks for assisting me on this issue.&nbsp; The problem, as you pointed out all along, had to do with performing a save without a tx.&nbsp; It polluted the second level cache so I wasn&#39;t testing with the environment I was expecting.<br>




<br>Cheers,<br><font color="#888888">&nbsp;craig</font><div><div></div><div><br><br><div class="gmail_quote">On Mon, Sep 8, 2008 at 10:39 PM, James Kovacs <span dir="ltr">&lt;<a href="mailto:[email protected]" target="_blank">[email protected]</a>&gt;</span> wrote:<br>



<blockquote class="gmail_quote" style="border-left:1px solid rgb(204, 204, 204);margin:0pt 0pt 0pt 0.8ex;padding-left:1ex">
<div dir="ltr">In order for the entity to be saved, you need to commit the tx. In the test, you should probably purge the 2nd level cache by evicting the serialized entity.<div><br></div><div>sessionFactory.Evict(typeof(Foo));</div>





<div><br></div><div>will remove all serialized Foo objects from the 2nd level cache. To evict only one:</div><div><br></div><div>sessionFactory.Evict(typeof(Foo), id);<br><font color="#888888"><div><br></div><div>James<br>




</div></font><div><div>--<br>James Kovacs, B.Sc., M.Sc., MCSD, MCT<br>
Microsoft MVP - C# Architecture<br><a href="http://www.jameskovacs.com" target="_blank">http://www.jameskovacs.com</a><br><a href="mailto:[email protected]" target="_blank">[email protected]</a><br>403-397-3177 (mobile)<br>





<br><br></div><div><div></div><div><div class="gmail_quote">On Mon, Sep 8, 2008 at 6:04 PM, Craig Neuwirt <span dir="ltr">&lt;<a href="mailto:[email protected]" target="_blank">[email protected]</a>&gt;</span> wrote:<br>




<blockquote class="gmail_quote" style="border-left:1px solid rgb(204, 204, 204);margin:0pt 0pt 0pt 0.8ex;padding-left:1ex">
<div dir="ltr"><div>Ayende,</div>
<div>&nbsp;</div>
<div>&nbsp; Thanks for the feedback.&nbsp; However, I believe the Saving operation is polluting the test.&nbsp; I want my test to demonstrate the ability to execute a query against EXISTING data in the database and have that query put in the query cache so that the next time I execute the same query, it uses the cache instead of hitting the db.</div>







<div>&nbsp;</div>
<div>So&nbsp;to test this, a&nbsp;Foo needs to be&nbsp;in the db and&nbsp;this part needs to be removed <br></div>
<div><div>&nbsp;using (ISession s = OpenSession())<br style="background-color:rgb(255, 255, 51)"><span style="background-color:rgb(255, 255, 51)">&nbsp;&nbsp;&nbsp; using (ITransaction tx = s.BeginTransaction())</span><br>&nbsp;&nbsp;&nbsp; {<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; s.Save(foo);<br>
&nbsp;&nbsp;<span style="background-color:rgb(255, 255, 51)">&nbsp; &nbsp;&nbsp;&nbsp; tx.Commit();</span> 
<div><br style="background-color:rgb(255, 255, 51)"><span style="background-color:rgb(255, 255, 51)">&nbsp;&nbsp;&nbsp; }</span><br></div>
</div><div>Isn&#39;t this the normal way of using the query cache?</div>
<div>&nbsp;</div>
<div>thanks.</div>
<div>&nbsp;craig<font color="#888888"><br></font></div></div><div><div></div><div>
<div class="gmail_quote">On Mon, Sep 8, 2008 at 3:07 PM, Ayende Rahien <span dir="ltr">&lt;<a href="mailto:[email protected]" target="_blank">[email protected]</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="border-left:1px solid rgb(204, 204, 204);margin:0px 0px 0px 0.8ex;padding-left:1ex">
<div dir="ltr">Blah!<br>We were looking at the wrong spot all along.<br>This test works, I marked the parts that I had to change.<br><br>Perfectly obvious, when you think of this.<br>You asked NHibernate to create new foo, so it has to put it in the cache and invalidate all Foos until the transaction is commited.<br>






It does so by specifying a timeout value of one minute from now (IIRC), which obivously mixes up with the test timing.<br><br>When the tx is commited, NH can make this visible again, and set it to the current timestamp.<br>






<br><br>[Test]<br>public void DoesNotLoadEntityFromSysCache()<br>{<br>&nbsp;&nbsp;&nbsp; Foo foo = new Foo();<br>&nbsp;&nbsp;&nbsp; foo.Name = &quot;Craig&quot;; 
<div><br><br>&nbsp;&nbsp;&nbsp; using (ISession s = OpenSession())<br style="background-color:rgb(255, 255, 51)"><span style="background-color:rgb(255, 255, 51)">&nbsp;&nbsp;&nbsp; using (ITransaction tx = s.BeginTransaction())</span><br>
&nbsp;&nbsp;&nbsp; {<br></div>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; s.Save(foo);<br>&nbsp;&nbsp;<span style="background-color:rgb(255, 255, 51)">&nbsp; &nbsp;&nbsp;&nbsp; tx.Commit();</span> 
<div><br style="background-color:rgb(255, 255, 51)"><span style="background-color:rgb(255, 255, 51)">&nbsp;&nbsp;&nbsp; }</span><br><br>&nbsp;&nbsp;&nbsp; using (ISession s = OpenSession())<br>&nbsp;&nbsp;&nbsp; using( ITransaction tx = s.BeginTransaction())<br>



&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Foo result = (Foo)s.CreateCriteria(typeof(Foo))<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; .Add(Property.ForName(&quot;Name&quot;).Eq(&quot;Craig&quot;))<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; .SetCacheable(true)<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; .UniqueResult();<br><br></div>






&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Assert.IsNotNull(result);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; tx.Commit(); 
<div><br>&nbsp;&nbsp;&nbsp; }<br><br>&nbsp;&nbsp;&nbsp; using (ISession s = OpenSession())<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; using (IDbCommand command = s.Connection.CreateCommand())<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; command.CommandText = &quot;DELETE FROM Foos&quot;;<br>






&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; command.ExecuteNonQuery();<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; }<br><br>&nbsp;&nbsp;&nbsp; using (ISession s = OpenSession())<br>&nbsp;&nbsp;&nbsp; using (ITransaction tx = s.BeginTransaction())<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Foo result = (Foo)s.CreateCriteria(typeof(Foo))<br>






&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; .Add(Property.ForName(&quot;Name&quot;).Eq(&quot;Craig&quot;))<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; .SetCacheable(true)<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; .UniqueResult();<br><br></div>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Assert.IsNotNull(result);<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; tx.Commit(); 
<div><br>&nbsp;&nbsp;&nbsp; }<br><br>&nbsp;&nbsp;&nbsp; using (ISession s = OpenSession())<br>&nbsp;&nbsp;&nbsp; using (ITransaction tx = s.BeginTransaction())<br>&nbsp;&nbsp;&nbsp; {<br></div>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; s.Delete(&quot;from Foo&quot;);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; s.Flush();<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; tx.Commit(); 
<div>
<div></div>
<div><br>&nbsp;&nbsp;&nbsp; }<br>}<br><br>
<div class="gmail_quote">On Mon, Sep 8, 2008 at 10:47 PM, Craig Neuwirt <span dir="ltr">&lt;<a href="mailto:[email protected]" target="_blank">[email protected]</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="border-left:1px solid rgb(204, 204, 204);margin:0pt 0pt 0pt 0.8ex;padding-left:1ex">
<div dir="ltr">Yeah, that&#39;s what I eluded to on my first post.&nbsp; <br><br>Thanks for letting me know I am not completely crazy yet ;-) 
<div>
<div></div>
<div><br><br>
<div class="gmail_quote">On Mon, Sep 8, 2008 at 1:28 PM, Ayende Rahien <span dir="ltr">&lt;<a href="mailto:[email protected]" target="_blank">[email protected]</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="border-left:1px solid rgb(204, 204, 204);margin:0pt 0pt 0pt 0.8ex;padding-left:1ex">
<div dir="ltr">I think there is still something funny going on, looks to be related to the time stamps that were going on there. 
<div>
<div></div>
<div><br><br><br>
<div class="gmail_quote">On Mon, Sep 8, 2008 at 9:20 PM, James Kovacs <span dir="ltr">&lt;<a href="mailto:[email protected]" target="_blank">[email protected]</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="border-left:1px solid rgb(204, 204, 204);margin:0pt 0pt 0pt 0.8ex;padding-left:1ex">
<div dir="ltr">I modified your patch to use transactions and SysCache worked for me as expected. I even debugged through and looked at the contents of the Foos table to verify that the IDbCommand did in fact delete the row. I&#39;ve since reverted the code, but can re-create it tonight when I get home. 
<div><br></div>
<div>
<div>James<br clear="all">--<br>James Kovacs, B.Sc., M.Sc., MCSD, MCT<br>Microsoft MVP - C# Architecture<br><a href="http://www.jameskovacs.com/" target="_blank">http://www.jameskovacs.com</a><br><a href="mailto:[email protected]" target="_blank">[email protected]</a><br>






403-397-3177 (mobile)<br><br><br></div>
<div>
<div></div>
<div>
<div class="gmail_quote">On Mon, Sep 8, 2008 at 12:16 PM, Craig Neuwirt <span dir="ltr">&lt;<a href="mailto:[email protected]" target="_blank">[email protected]</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="border-left:1px solid rgb(204, 204, 204);margin:0pt 0pt 0pt 0.8ex;padding-left:1ex">
<div dir="ltr">So, was their actually a determination made whether or not SysCache is working as expected or there is actually a problem.&nbsp; If it is the former, can someone please show me how to make it work (you can make updates the patch I submitted)<br>






<br>thanks,<br><font color="#888888">&nbsp; craig</font> 
<div>
<div></div>
<div><br><br>
<div class="gmail_quote">On Sun, Sep 7, 2008 at 7:02 PM, Ayende Rahien <span dir="ltr">&lt;<a href="mailto:[email protected]" target="_blank">[email protected]</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="border-left:1px solid rgb(204, 204, 204);margin:0pt 0pt 0pt 0.8ex;padding-left:1ex">
<div dir="ltr">You have to commit the transaction.<br>NH requires transactions for reads as well. 
<div>
<div></div>
<div><br><br>
<div class="gmail_quote">On Mon, Sep 8, 2008 at 2:53 AM, Craig Neuwirt <span dir="ltr">&lt;<a href="mailto:[email protected]" target="_blank">[email protected]</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="border-left:1px solid rgb(204, 204, 204);margin:0pt 0pt 0pt 0.8ex;padding-left:1ex">
<div dir="ltr">Hey James,<br><br>&nbsp; You are absolutely correct.&nbsp; Once I added the transaction, my unit test passed.&nbsp; However, the actual scenario I am trying to get working is assuming data is in the db already and I perform an initial query.&nbsp; I want that result to go into the second level cache so it is retrieved from the cache when the same query is executed.&nbsp; How do I make that happen?&nbsp; I tried putting transaction around the query, but that didn&#39;t work and I don&#39;t think that should be necessary for reads.<br>






<br>thanks,<br><font color="#888888">craig</font> 
<div>
<div></div>
<div><br><br>
<div class="gmail_quote">On Sun, Sep 7, 2008 at 5:14 PM, James Kovacs <span dir="ltr">&lt;<a href="mailto:[email protected]" target="_blank">[email protected]</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="border-left:1px solid rgb(204, 204, 204);margin:0pt 0pt 0pt 0.8ex;padding-left:1ex">
<div dir="ltr">I am looking at it right now. Initial investigations... The problem seems to stem from lack of transaction handling in the test case. If rather than flushing the session, you commit a transaction, the SysCache returns data appropriately. I&#39;ll post more as I find out more. (Just posting to save Ayende some time.)<br>






<br>James<br clear="all"><font color="#888888">--<br>James Kovacs, B.Sc., M.Sc., MCSD, MCT<br>Microsoft MVP - C# Architecture<br><a href="http://www.jameskovacs.com/" target="_blank">http://www.jameskovacs.com</a><br><a href="mailto:[email protected]" target="_blank">[email protected]</a><br>






403-397-3177 (mobile)</font> 
<div>
<div></div>
<div><br><br><br>
<div class="gmail_quote">On Sun, Sep 7, 2008 at 4:07 PM, Ayende Rahien <span dir="ltr">&lt;<a href="mailto:[email protected]" target="_blank">[email protected]</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="border-left:1px solid rgb(204, 204, 204);margin:0pt 0pt 0pt 0.8ex;padding-left:1ex">
<div dir="ltr">Guys,<br>I am going to look at the issue now, will post my results soon 
<div>
<div></div>
<div><br><br>
<div class="gmail_quote">On Sun, Sep 7, 2008 at 10:44 PM, Gildas <span dir="ltr">&lt;<a href="mailto:[email protected]" target="_blank">[email protected]</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="border-left:1px solid rgb(204, 204, 204);margin:0pt 0pt 0pt 0.8ex;padding-left:1ex"><br>Fabio, I know that I&#39;m still noob in NHibernate and that I may ask<br>stupid questions. I&#39;m sorry if you are bored with this, but well,<br>






please understand that I&#39;m just trying to resolve a problem I did not<br>have before upgrading to last NHibernate trunk.<br><br>Going through Rhino code, I can see that my session is created at each<br>request, so that&#39;s not the problem.<br>






Anyway, I still don&#39;t have any second level cache. Items are updated<br>but never retrieved from it.<br><br>Can someone check the test case from craig, which is failing and don&#39;t<br>use any fancy session management ?<br>






<br>Thanks<br><br>On Sep 7, 8:35&nbsp;pm, &quot;Fabio Maulo&quot; &lt;<a href="mailto:[email protected]" target="_blank">[email protected]</a>&gt; wrote:<br>&gt; 2008/9/7 Gildas &lt;<a href="mailto:[email protected]" target="_blank">[email protected]</a>&gt;<br>







<div>
<div></div>
<div>&gt;<br>&gt;<br>&gt;<br>&gt; &gt; So I&#39;m going to ask if this is the right way to handle sessions ? From<br>&gt; &gt; what I remember of NHibernate, NH Sessions must not be stored in<br>&gt; &gt; HttpContext.Session. I may not understand the reasons why this done<br>






&gt; &gt; like this in UnitOfWorkApplication, maybe for long transactions<br>&gt; &gt; management ?<br>&gt;<br>&gt; Rhino UoW use httpSession only for long conversation...<br>&gt; The NhSession CAN be stored in the httpSession simply because is the &quot;most<br>






&gt; simple&quot; way to manage long-conversations.<br>&gt; --<br>&gt; Fabio Maulo<br><br></div></div></blockquote></div><br></div></div></div>
<div>
<div></div>
<div><br><br></div></div></blockquote></div><br></div></div></div>
<div>
<div></div>
<div><br><br></div></div></blockquote></div><br></div></div></div>
<div>
<div></div>
<div><br><br></div></div></blockquote></div><br></div></div></div>
<div>
<div></div>
<div><br><br></div></div></blockquote></div><br></div></div></div>
<div>
<div></div>
<div><br><br></div></div></blockquote></div><br></div></div></div></div>
<div>
<div></div>
<div><br><br></div></div></blockquote></div><br></div></div></div>
<div>
<div></div>
<div><br><br></div></div></blockquote></div><br></div></div></div>
<div>
<div></div>
<div><br><br></div></div></blockquote></div><br></div></div></div>
<div>
<div></div>
<div>
<br>
</div></div></blockquote></div></div></div></div></blockquote></div><br></div></div></div></div></div><div><div></div><div><br>
<br>
</div></div></blockquote></div><br></div></div></div><div><div></div><div><br>
<br>
</div></div></blockquote></div><br></div></div></div><div><div></div><div><br>
<br>
</div></div></blockquote></div><br></div></div></div><div><div></div><div><br>
--~--~---------~--~----~------------~-------~--~----~<br>
You received this message because you are subscribed to the Google Groups &quot;nhusers&quot; group. <br> To post to this group, send email to <a href="mailto:[email protected]" target="_blank">[email protected]</a> <br>

 To unsubscribe from this group, send email to <a href="mailto:nhusers%[email protected]" target="_blank">[email protected]</a> <br> For more options, visit this group at <a href="http://groups.google.com/group/nhusers?hl=en" target="_blank">http://groups.google.com/group/nhusers?hl=en</a> <br>

 -~----------~----~----~----~------~----~------~--~---<br>
<br>
</div></div></blockquote></div><br></div></div></div></div></div>
</div><br></div></div>

------=_Part_56483_6801918.1220978125394--


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

--===============0590902211==--