there are various patterns to implements and many implemented.Patterns are:
open-session-in-view (aka session-per-request)
session-per-conversation (aka long-session)
session-per-application-transaction (few doc)

Implementation are available in:
Rhino UnitOfWork
Spring NH integration
Castle NH facilities
NHibernate.Burrow
uNhAddIns session Easier

The pattern you are describing is: session-per-conversation described in
NHibernate in Action book and here ( http://www.hibernate.org/42.html )

In a real app you may use:
1) session-per-request (for whole app)
2) mix session-per-request with session-per-conversation
3) in some complex scenario or in
winForm, session-per-application-transaction or some it's special
implementation.


2008/12/9 Fredy Treboux <[EMAIL PROTECTED]>

>
> Hello everybody, first message to the list.
>
> I'm writing my first application using NHibernate..
> It's actually a wizard (winforms), and i'm trying to use it to learn
> as much as i can..
> Basically, the app loads a bunch of entities based on an input file,
> then validates them against a given criteria, and modify some
> properties on the valid ones.
> The modification part must be completly atomic (all entities modified
> in the same transaction, so no changes to the db are made if some
> fail).
>
> I'm using a singleton class to get sessions from the Session factory
> based on some 'context' i define.
> (and also looking for a better way to do it, but that's not the
> important part of this e-mail)
> In one of my 'upper layers' i call "StartContext", and "EndContext" to
> delimitate a context in which the same Session will be given (to the
> DAO's) by that singleton..
> if i don't 'mark' the context like that a new session is created by it
> for every operation.
>
> My question is, would it be a good practice to use a single session
> for the duration of the whole wizard dialog?
> ("StartContext" at the beginning of the dialog, "EndContext" when it
> finishes)
> And, if i do this, would it be bad if i start and end multiple
> transactions on it?.
>
> Or should i make my sessions shorter?..(take into account that
> validation and modification processes are minutes long)
> I guess making my sessions shorter would mean that i should use second
> level cahche to avoid reloading entities between validation and
> modification?..
>
> If someone could answer my questions, give me any insight or
> suggestion, or yell to me for completly missing the point... it would
> be welcome.
>
> Many thanks in advance.
>
> >
>


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

Reply via email to