[hibernate-dev] Session opening

Steve Ebersole steve at hibernate.org
Fri Apr 1 09:25:05 EDT 2011


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 SessionFactory.withOptions() 
which returns a org.hibernate.SessionBuilder instance which can be used to 
specify the options with which you want the Session built by eventually 
calling openSession() on it.  For example:

Session session = sessionFactory
        .withOptions()
        .connection( someConnection )
        .openSession();

The only prior form I left is openSession()

There is also a means to create a Session using certain information from an 
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>
http://hibernate.org



More information about the hibernate-dev mailing list