Hi HP,

I'll go with option 1 but let me ask a question: are you experiencing
performance problems? Do you ran tests that mimic realistically production
conditions and the results show that you need to optimize?

If your answer is NO to both questions, I'd recommend to go with the
simplest solution, that is, session per request with optimistic locking on.

Remember that working with objects, abstracted from the persistence has
value and is desirable (at lease to the vast majority of readers of this
group), so, try hard not to deviate to early (an probably unnecessary)
optimization which will bring a harder to maintain design.

Kind regards

Carlos Peix 

-----Mensaje original-----
De: [email protected] [mailto:[EMAIL PROTECTED] En nombre de
HP
Enviado el: Domingo, 12 de Octubre de 2008 12:38 p.m.
Para: nhusers
Asunto: [nhusers] Session per request, updating entities without reloading
them from db.


Hi there


The most popular approach to using NH with asp.net is session per request
model. So, in one request I load some data, present them to the user and
close the session. In the next request the user wants to modify the data,
eg. modify the order of items in a listbox that correspond to some ordered
entities collection.

On the server side, I receive the list of object ID's, and their new
ordering numbers. The question is: how to persist this update back to the
db? Do I have to reload entities based on their IDs, change ordering and
update them?
It seems like a huge waste - I don't need any information from db, I have
everything right here: IDs and the new ordering, I don't need the rest of
their fields.

On the other hand I could use Session Per Conversation pattern along with
saving entities in the session. But this time I create unnecessary memory
overhead, since I'm keeping in session data, that I already have on a
webform. It breaks the "stateless" part of http, where usually statless
means also scalable.

So I'd rather use the first route, but is there any way to do it without
handcrafting the update with CreateSqlQuery? Is there any way to use some
dummy object (like entity without not null constraints) to pass to
nhibernate only fields that should be updated, along with object id?


thanks a lot
HP


--~--~---------~--~----~------------~-------~--~----~
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]
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to