-->
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.  [ 2 posts ] 
Author Message
 Post subject: Session Connection
PostPosted: Mon Mar 21, 2005 10:10 pm 
Newbie

Joined: Fri Mar 11, 2005 7:22 pm
Posts: 7
If I fetch a connection from a session, am I asking the session for his connection or will he give me one from the connection pool?

Case in point:

1.) I ask the session for a db connection.
2.) Do some db procedure junk.
3.) Update an object in the session.
4.) Commit my transaction.
5.) Give the connection back.

Will the update of the object use the same connection I asked the session for?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 22, 2005 7:34 pm 
Regular
Regular

Joined: Tue Jun 22, 2004 8:01 pm
Posts: 106
Location: PowderTown, Utah, USA
As per the JavaDoc on net.sf.hibernate.Session:

public Connection connection()
throws HibernateException

Get the JDBC connection. Applications are responsible for calling commit/rollback upon the connection before closing the Session.

Returns:
the JDBC connection in use by the Session
Throws:
HibernateException - if the Session is disconnected

The Session.connection() method returns the Session's connection. It originates from the connection pool, but it is the connection currently in use by the session.

The answer is yes, any updates occuring during Session.flush will use that same connection.


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