I\'m reading the Hibernate documentation at present and I came across the following quote:
If the Session throws an exception, including any SQLException,
I've done a bit of digging into Hibernate:
Persistence sessions keep their life-cycle somewhat independent from JDBC connections. When you close Hibernate's Session
the connection is released. Exact meaning of "releasing connection" depends on how the connection was obtained in the first place:
sessionFactory.openStatelessSession(connection)
) you will get your connection with possibly unfinished transaction back when calling session.close()session.close()
will usually end up in calling connection.close()
No automatic session flushing or transaction commit / rollback is made by Hibernate. The same states for the JPA's EntityManager.
So what happens in the end depends on your connection provider / data source. With C3PO any unfinished transaction will be rolled-back when the connection is returned to the pool. On the other hand if you have managed JTA connection then the actual transaction handling might be completely out of scope to your application.