﻿<?xml version="1.0" encoding="utf-8"?><rss version="2.0"><channel><title>Ayende @ Rahien</title><link>http://ayende.com</link><description>Ayende @ Rahien</description><copyright>Copyright (C) Ayende Rahien  2004 - 2021 (c) 2026</copyright><ttl>60</ttl><item><title>Imran commented on Nhibernate Unit of Work &amp; multiple reuqests</title><description>Set,
  
You mentioned avoiding session state. Just wondering how you usually implement long conversations without using session state?
</description><link>http://ayende.com/4117/nhibernate-unit-of-work-multiple-reuqests#comment23</link><guid>http://ayende.com/4117/nhibernate-unit-of-work-multiple-reuqests#comment23</guid><pubDate>Tue, 01 Sep 2009 12:04:21 GMT</pubDate></item><item><title>Ayende Rahien commented on Nhibernate Unit of Work &amp; multiple reuqests</title><description>DaRage,
  
Yes, it probably will.
  
If you care about that, take a look at Merge
</description><link>http://ayende.com/4117/nhibernate-unit-of-work-multiple-reuqests#comment22</link><guid>http://ayende.com/4117/nhibernate-unit-of-work-multiple-reuqests#comment22</guid><pubDate>Fri, 14 Aug 2009 21:27:45 GMT</pubDate></item><item><title>DaRage commented on Nhibernate Unit of Work &amp; multiple reuqests</title><description>Ayende,
  
  
But it will still increment the version number, right? 
  
  
The reason I asked this is that if I wrap the 2 requests in a conversation and keep the original NH session in ASP.NET session, then if the use makes no changes to the entity NH will not update it.
  
  
so it's kind of we have to use conversations anyway because they're very common just like in this scenario and the session-per-request pattern is not sufficient in most cases. 
  
  
Please correct me if I'm wrong.
</description><link>http://ayende.com/4117/nhibernate-unit-of-work-multiple-reuqests#comment21</link><guid>http://ayende.com/4117/nhibernate-unit-of-work-multiple-reuqests#comment21</guid><pubDate>Fri, 14 Aug 2009 13:27:00 GMT</pubDate></item><item><title>Ayende Rahien commented on Nhibernate Unit of Work &amp; multiple reuqests</title><description>DaRage,
  
If so, to its original values, with is a no op anyway, so you wouldn't care.
</description><link>http://ayende.com/4117/nhibernate-unit-of-work-multiple-reuqests#comment20</link><guid>http://ayende.com/4117/nhibernate-unit-of-work-multiple-reuqests#comment20</guid><pubDate>Fri, 14 Aug 2009 00:10:47 GMT</pubDate></item><item><title>DaRage commented on Nhibernate Unit of Work &amp; multiple reuqests</title><description>Ayende,
  
  
What if the user didn't change anything will the row still be updated?
  
</description><link>http://ayende.com/4117/nhibernate-unit-of-work-multiple-reuqests#comment19</link><guid>http://ayende.com/4117/nhibernate-unit-of-work-multiple-reuqests#comment19</guid><pubDate>Thu, 13 Aug 2009 19:48:48 GMT</pubDate></item><item><title>Ayende Rahien commented on Nhibernate Unit of Work &amp; multiple reuqests</title><description>DaRage,
  
No need to do anything else, just materialize the values from the client (including the version number that the user editted) and call Update on it.
  
That would cause NH to update the row, and we use the version number to ensure concurrency control
</description><link>http://ayende.com/4117/nhibernate-unit-of-work-multiple-reuqests#comment18</link><guid>http://ayende.com/4117/nhibernate-unit-of-work-multiple-reuqests#comment18</guid><pubDate>Thu, 13 Aug 2009 19:31:58 GMT</pubDate></item><item><title>DaRage commented on Nhibernate Unit of Work &amp; multiple reuqests</title><description>@Ayende
  
  
can you explain more? how does NH know if the entity has changed? does it fetch from the db and compare record by record and update if something has changed? are you suggesting to increment the version number manually? isn't the version number number manipulated internally by NH?
  
  
please explain more. Thanks.
</description><link>http://ayende.com/4117/nhibernate-unit-of-work-multiple-reuqests#comment17</link><guid>http://ayende.com/4117/nhibernate-unit-of-work-multiple-reuqests#comment17</guid><pubDate>Thu, 13 Aug 2009 19:23:27 GMT</pubDate></item><item><title>Mr_Simple commented on Nhibernate Unit of Work &amp; multiple reuqests</title><description>I'm with you Tyler.  Keep it simple.  My head hurts from all the mental gymnastics being discussed.
</description><link>http://ayende.com/4117/nhibernate-unit-of-work-multiple-reuqests#comment16</link><guid>http://ayende.com/4117/nhibernate-unit-of-work-multiple-reuqests#comment16</guid><pubDate>Thu, 13 Aug 2009 19:07:41 GMT</pubDate></item><item><title>Ayende Rahien commented on Nhibernate Unit of Work &amp; multiple reuqests</title><description>Rafal &amp; Kelly,
  
Yes, NH support serialization of the session.
  
  
Kelly,
  
Wait for it, really wait for it.
  
  
Set,
  
SqlTransaction inside ASP.Net Sessions.
  
You make me want to cry again.
  
  
DaRage,
  
You use versioning, and just update the instance. NH takes care of everything else.
  
  
vbedegi,
  
It seems like if you can't use session per conversation, you can just keep the state on the client, no need to do applications of diffs.
</description><link>http://ayende.com/4117/nhibernate-unit-of-work-multiple-reuqests#comment15</link><guid>http://ayende.com/4117/nhibernate-unit-of-work-multiple-reuqests#comment15</guid><pubDate>Thu, 13 Aug 2009 18:48:56 GMT</pubDate></item><item><title>Ayende Rahien commented on Nhibernate Unit of Work &amp; multiple reuqests</title><description>Neil,
  
If that is the case, then you need to make sure that your entities are serializable. The session itself is.
  
Theoretically, you can serialize it back &amp; forth between servers.
  
In practice, I would feel much better if you used sticky sessions, though.
</description><link>http://ayende.com/4117/nhibernate-unit-of-work-multiple-reuqests#comment14</link><guid>http://ayende.com/4117/nhibernate-unit-of-work-multiple-reuqests#comment14</guid><pubDate>Thu, 13 Aug 2009 18:40:18 GMT</pubDate></item><item><title>Ayende Rahien commented on Nhibernate Unit of Work &amp; multiple reuqests</title><description>Rik,
  
Caching?
</description><link>http://ayende.com/4117/nhibernate-unit-of-work-multiple-reuqests#comment13</link><guid>http://ayende.com/4117/nhibernate-unit-of-work-multiple-reuqests#comment13</guid><pubDate>Thu, 13 Aug 2009 18:36:44 GMT</pubDate></item><item><title>vbedegi commented on Nhibernate Unit of Work &amp; multiple reuqests</title><description>Right now, I am searching for the holy pattern to span a session through multiple requests. One approach could be to record every request, that  modifies the entity, and before each request, just replay (re-apply) them on the entity. This would work for very simple scenarios, but often, the commands take effect on a whole aggregate, not just a standalone entity.  
  
So now, the session-per-conversation pattern seems to be the most viable solution for me, with all of it's limitations. Until you suggest me a better one...
</description><link>http://ayende.com/4117/nhibernate-unit-of-work-multiple-reuqests#comment12</link><guid>http://ayende.com/4117/nhibernate-unit-of-work-multiple-reuqests#comment12</guid><pubDate>Thu, 13 Aug 2009 17:16:55 GMT</pubDate></item><item><title>DaRage commented on Nhibernate Unit of Work &amp; multiple reuqests</title><description>Question: how does the session per request deal with this very common scenario: a user retrieve the data for viewing in the first request and edits and submit his changes in a second request.
  
  
You can argue to re-attach the entity on the second request but you will lose all the tracking information.
</description><link>http://ayende.com/4117/nhibernate-unit-of-work-multiple-reuqests#comment11</link><guid>http://ayende.com/4117/nhibernate-unit-of-work-multiple-reuqests#comment11</guid><pubDate>Thu, 13 Aug 2009 17:09:09 GMT</pubDate></item><item><title>Fabio Maulo commented on Nhibernate Unit of Work &amp; multiple reuqests</title><description>@Tyler
  
Exactly what I mean with "WEB app should have it in mind".
</description><link>http://ayende.com/4117/nhibernate-unit-of-work-multiple-reuqests#comment10</link><guid>http://ayende.com/4117/nhibernate-unit-of-work-multiple-reuqests#comment10</guid><pubDate>Thu, 13 Aug 2009 16:34:19 GMT</pubDate></item><item><title>Tyler Burd commented on Nhibernate Unit of Work &amp; multiple reuqests</title><description>For requests that span multiple pages I generally don't write the data to the actual entity until the very last screen is submitted.  I keep track of the previous pages' data via hidden form fields.  OR, I create a separate persistent model solely to save the user's progress.  When the last screen is complete I then copy that "form" entity's data into the "business" entity.
  
  
This does seem like more work at the outset, but it's a hell of a lot easier than managing a long conversation by dropping the NH session into the ASP session and all of the problems with concurrency that creates.
</description><link>http://ayende.com/4117/nhibernate-unit-of-work-multiple-reuqests#comment9</link><guid>http://ayende.com/4117/nhibernate-unit-of-work-multiple-reuqests#comment9</guid><pubDate>Thu, 13 Aug 2009 16:28:57 GMT</pubDate></item><item><title>Fabio Maulo commented on Nhibernate Unit of Work &amp; multiple reuqests</title><description>Simple long-conversation management
  
[code.google.com/.../NHExtendedSessionWebModule.cs](http://code.google.com/p/unhaddins/source/browse/trunk/uNhAddIns/uNhAddIns.Web/NHExtendedSessionWebModule.cs)  
  
Restriction: only one long conv. allowed
  
  
This is the other pattern
  
[fabiomaulo.blogspot.com/.../...nversation-per.html](http://fabiomaulo.blogspot.com/2009/01/aspect-conversation-per.html)  
  
Note: the usage of long conversation are not recommended in applications where the hardware scalability is mandatory. session-per-request is the better pattern in WEB and and the design of the WEB app should have it in mind. 
  
</description><link>http://ayende.com/4117/nhibernate-unit-of-work-multiple-reuqests#comment8</link><guid>http://ayende.com/4117/nhibernate-unit-of-work-multiple-reuqests#comment8</guid><pubDate>Thu, 13 Aug 2009 16:02:25 GMT</pubDate></item><item><title>Set commented on Nhibernate Unit of Work &amp; multiple reuqests</title><description>&gt;but is that really a good idea?
  
  
From my point of view, I hate aspnet session, now I avoid these like plague, it's not yet to the point of viewstate and dataset but I feel it'll be soon reaching that point...
  
  
Unfortunnatly, at work I've seen SqlTransaction objects being serialized inside asp.net session inside web services... :( 
  
Happily that I don't have to look much into the code of these WS...
</description><link>http://ayende.com/4117/nhibernate-unit-of-work-multiple-reuqests#comment7</link><guid>http://ayende.com/4117/nhibernate-unit-of-work-multiple-reuqests#comment7</guid><pubDate>Thu, 13 Aug 2009 14:38:57 GMT</pubDate></item><item><title>Kelly Stuard commented on Nhibernate Unit of Work &amp; multiple reuqests</title><description>On a side note: the "future posts" section gives me something to look forward to. For instance, the "8 days: Help requests that make me want to cry" sounds like a good one.
</description><link>http://ayende.com/4117/nhibernate-unit-of-work-multiple-reuqests#comment6</link><guid>http://ayende.com/4117/nhibernate-unit-of-work-multiple-reuqests#comment6</guid><pubDate>Thu, 13 Aug 2009 14:20:44 GMT</pubDate></item><item><title>DaRage commented on Nhibernate Unit of Work &amp; multiple reuqests</title><description>Also, using the ASP.NET session doesn't scale.
</description><link>http://ayende.com/4117/nhibernate-unit-of-work-multiple-reuqests#comment5</link><guid>http://ayende.com/4117/nhibernate-unit-of-work-multiple-reuqests#comment5</guid><pubDate>Thu, 13 Aug 2009 14:19:00 GMT</pubDate></item><item><title>Neil Barnwell commented on Nhibernate Unit of Work &amp; multiple reuqests</title><description>You suggest putting the NHibernate session in the ASP.NET session, but is that really a good idea?  What if you are load balancing the web servers?  What if you are using SQL Session Persistence?
</description><link>http://ayende.com/4117/nhibernate-unit-of-work-multiple-reuqests#comment4</link><guid>http://ayende.com/4117/nhibernate-unit-of-work-multiple-reuqests#comment4</guid><pubDate>Thu, 13 Aug 2009 14:11:05 GMT</pubDate></item><item><title>Kelly Stuard commented on Nhibernate Unit of Work &amp; multiple reuqests</title><description>I'm curious how you have the UOW span multiple requests when you are in a multi-server webfarm. Does nHib session work ok when de-/re-serialized through the out-of-proc session state providers?
</description><link>http://ayende.com/4117/nhibernate-unit-of-work-multiple-reuqests#comment3</link><guid>http://ayende.com/4117/nhibernate-unit-of-work-multiple-reuqests#comment3</guid><pubDate>Thu, 13 Aug 2009 13:48:13 GMT</pubDate></item><item><title>Rik Hemsley commented on Nhibernate Unit of Work &amp; multiple reuqests</title><description>"It is much easier to build your application so each request is a single unit of work."
  
  
When a user is 'building' a possibly-temporary entity from the (web) UI, they may cause dozens of requests when moving between pages and with AJAX.
  
  
I'm interested to know how you (Oren) handle this common situation without a unit of work which spans HTTP requests.
  
</description><link>http://ayende.com/4117/nhibernate-unit-of-work-multiple-reuqests#comment2</link><guid>http://ayende.com/4117/nhibernate-unit-of-work-multiple-reuqests#comment2</guid><pubDate>Thu, 13 Aug 2009 12:01:01 GMT</pubDate></item><item><title>Rafal commented on Nhibernate Unit of Work &amp; multiple reuqests</title><description>Hi, having such feature is very convenient. In the company I'm working for we are using 'Sooda' ORM and it's capable of serializing and deserializing transaction state. Using this we can implement long living 'transactions' that span multiple http requests. Transaction state is serialized to xml files, so even in case of application restart users will not lose their uncommited data and can continue working as if nothing happened. BTW by transaction state I mean the state of all objects inserted or modified in single ORM session. I havent yet tried to do the same with NHibernate, but hope it's possible.
</description><link>http://ayende.com/4117/nhibernate-unit-of-work-multiple-reuqests#comment1</link><guid>http://ayende.com/4117/nhibernate-unit-of-work-multiple-reuqests#comment1</guid><pubDate>Thu, 13 Aug 2009 10:56:48 GMT</pubDate></item></channel></rss>