I am new to hibernate but have been helping someone debug an issue they were having.
In the code they were getting the hibernate connection to reuse it outside of the hibernate transaction like this:
Code:
Session sesssion = SessionFactory.openSession();
.
.
.
Connection conn = session.connection();
PreparedStatement pstmt = conn.prepareStatement("someQuery");
.
.
.
conn.close();
Now the problem here is obviously that the connection shouldn't be being reused and closed like this. However, when the session is closed and a subsequent call to SessionFactory.OpenSession() is made the session it returns generates errors because the connection is closed.
It was my understanding that when calling openSession() from a SessionFactory it got a new connection.
Can someone explain how the SessionFactory is actually handling the connections?
There is nothing in hibernate.cfg.xml that specifies any kind of connection pooling.
Thanks in advance,
Ian