[hibernate-dev] Session opening

Shawn Clowater shawn.clowater at Entero.com
Fri Apr 1 12:05:34 EDT 2011


Saw this yesterday.  Looks like I'll be able to remove my patch that is
currently allowing me to inject my session factory into session obtained
from a getCurrentSession() call which makes me very happy.  I'll dig up
the JIRA so you guys can kill it.

One question though, with the session.sessionWithOptions() will that
steal the connection from the underlying session?  

Background: We've got some places where we want to execute a query with
an alternate set of filters and rather than muck with the ones on the
existing session we'll use session.connection() and spin a new one and
set the particular filters we want, do the query and then close the
session().  That just leaves the original session isolated from having a
bunch of additional data loaded into and also prevents data from being
locked into it with the temporary filter view of the data.  I just
wanted to ensure that this will still be possible.

Shawn Clowater

-----Original Message-----
From: hibernate-dev-bounces at lists.jboss.org
[mailto:hibernate-dev-bounces at lists.jboss.org] On Behalf Of Steve
Sent: Friday, April 01, 2011 7:25 AM
To: hibernate-dev at lists.jboss.org
Subject: [hibernate-dev] Session opening

RE: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2860

This dealt with cleaning up all the overloaded openSession methods from 
SessionFactory and SessionFactoryImplementor.

The new main method for obtaining a Session is
which returns a org.hibernate.SessionBuilder instance which can be used
specify the options with which you want the Session built by eventually 
calling openSession() on it.  For example:

Session session = sessionFactory
        .connection( someConnection )

The only prior form I left is openSession()

There is also a means to create a Session using certain information from
existing session using Session.sessionWithOptions() which returns a 
org.hibernate.SharedSessionBuilder (extending from SessionBuilder).

As part of this I was also finally able to remove the long deprecated 
Session.connection() method since we now have doWork, doReturningWork
and now 
session opening.

Any questions or concerns?

Steve Ebersole <steve at hibernate.org>
hibernate-dev mailing list
hibernate-dev at lists.jboss.org

More information about the hibernate-dev mailing list