Hi Guys,
I'm starting a project with nhibernate 3 (alpha2), and would like to check
with you if my session management is right.
The project is a windows service, running a lot of small threads.
I create like 15 ~20 new threads every 60 seconds, each thread lives for
10~40 seconds.
Each thread usually load/updates 10~100 entities.
Currently, everytime I start a new thread, I also start a session and a
transaction.
The code looks like this:
public void ValidateEntities(){
// creates a new session and a new nhibernate transaction, UnitOfWork is
just a wrapper around nhibernate session
using(var uow = UnitOfWorkFactory.Create()){
try{
var entities = myRepository.LoadAllEntitiesWithStatusX();
// some processing on entities
uow.commit();
} catch (Exception e){
uow.Rollback();
throw;
}
}
}
That's a correct way to do this?
Any tips to improve the code?
Regards,
Rafael
--
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.