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.  [ 3 posts ] 
Author Message
 Post subject: Connection pool in a session
PostPosted: Fri Sep 05, 2008 9:15 am 
Newbie

Joined: Fri Sep 05, 2008 8:46 am
Posts: 2
Hi,

I'm developping a swing application that uses the same session for the whole application. So the objects from the model are always bound to a session so that retrieve bounded objects when needed. (We don't access the data by queries but by using the lazy loading, all the objects can be accessed by a root node).

The probleme I have is that when the application starts a lot of data need to be loaded. So many threads are trying to load data using the same session. As there is only one connection bounded to a session, the connection becomes the bottleneck.

Is it possible for a session to use a pool of connection so that it can be used by many threads at the same time ?

If not, does someone see how benefits from many session without loading in memory many time the same physical object (row in the database) ?

I hope my question is clear enough...

Thanks for your suggestions and advises,

Dave


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 05, 2008 2:16 pm 
Expert
Expert

Joined: Wed Mar 03, 2004 6:35 am
Posts: 1240
Location: Lund, Sweden
Sessions are not thread-safe and should only be used by a single thread at a time. From the Session javadoc at http://www.hibernate.org/hib_docs/v3/ap ... ssion.html:

Quote:
It is not intended that implementors be threadsafe. Instead each thread/transaction should obtain its own instance from a SessionFactory.


There is a wiki page talking about various strategies for "thick" applications at: http://www.hibernate.org/333.html

Don't know if that will help and I am mainly into web applications were a session-per-request pattern is a kind of standard approach.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 08, 2008 10:52 am 
Newbie

Joined: Fri Sep 05, 2008 8:46 am
Posts: 2
Yes, that was very interesting. Thanks.

The link shows that the using Hibernate in a Thick-Client context brings hard-to-solve problems...

In our situation, our major concern is the loading time. If hibernate could use many connections in one session that would be perfect (we would not have to re-design the way our application deals with Hibernate).

Unfortunately it seems pretty clear that it is not possible...
Quote:
It is not intended that implementors be threadsafe. Instead each thread/transaction should obtain its own instance from a SessionFactory.


Warm regards,

Dave


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.