-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: Session is lightweight or heavyweight
PostPosted: Sat Dec 24, 2005 4:37 am 
Newbie

Joined: Mon Dec 05, 2005 10:02 am
Posts: 12
Hi All,

I am a bit confused about the session object being lightweight or heavyweight, in terms of database connection.
When I open a session is a database connection created or does NHibernate work with some kind of connection pool and assigns the session a connection from the pool?
Is it reasonable from performance and scalability point of view to have my Data Access Layer open a session upon each request, use it to retrieve the object and then immediately close it?
From the system design point of view it seems most sensible to me because I don't want the service and UI layers who use to Data Access Layer to be aware of sessions or use any NHibernate APIs.
I'm aware of the lazy loading concerns - I just might use the
reattachment method I found in the forum or some another technique.

Thanks In Advance
Dror


Top
 Profile  
 
 Post subject: Re: Session is lightweight or heavyweight
PostPosted: Sat Dec 24, 2005 6:28 am 
Senior
Senior

Joined: Sat May 14, 2005 8:40 am
Posts: 130
drorwe wrote:
When I open a session is a database connection created or does NHibernate work with some kind of connection pool and assigns the session a connection from the pool?


NHibernate depends on the specific ADO.NET providers for connection pooling. Most providers do connection pooling by default, so in those cases, the connections used by the Sessions are also pooled.

Quote:
Is it reasonable from performance and scalability point of view to have my Data Access Layer open a session upon each request, use it to retrieve the object and then immediately close it?
From the system design point of view it seems most sensible to me because I don't want the service and UI layers who use to Data Access Layer to be aware of sessions or use any NHibernate APIs.
I'm aware of the lazy loading concerns - I just might use the
reattachment method I found in the forum or some another technique.


Since you're aware of the potential drawbacks, I think it's fine to do it this way.

_________________
Cuyahoga


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 27, 2005 3:53 am 
Senior
Senior

Joined: Thu Aug 25, 2005 3:35 am
Posts: 160
when you say: the reattach method I've found in the forums, you mean the session.Lock(object, xx) method, don't you?[/i]


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 28, 2005 5:27 am 
Newbie

Joined: Mon Dec 05, 2005 10:02 am
Posts: 12
Yes, I mean the session.Lock method.

This technique seems quite elegant, but the thing I don't like about it is that it forces your persistent domain objects to "know" that they are persistent (because they must invoke some NHibernate API upon getting of a lazy collection).
This problem however is rather conceptual and from practical aspects this method seems fine.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.