TraderJoeChicago TraderJoeChicago - 1 year ago 79
Java Question

session.connection() deprecated on Hibernate?

We need to be able to get the associated

of a hibernate session. No other connection will work, as this connection may be associated with a running transaction.

If session.connection() is now deprecated, how am I supposed to do that?

Answer Source

You now have to use the Work API:

    new Work() {
        public void execute(Connection connection) throws SQLException 

Or, in Java 8 :

session.doWork(connection -> doSomething(connection));