When using Hibernate/JPA with c3p0, if multiple POs are being saved i.e. if records are being inserted into several tables, in the same database, within one (EntityManager) transaction, will hibernate use multiple connections to do this or simply use any one connection (from the connection pool)?
Best How To :
A transaction (such as that started by
begin() and commited by
javax.persistence.EntityTransaction) is associated with the same connection from resource pool.
For example, in
begin() will store a connection retrieved from the pool into a private variable called
managedConnection. When you call
commit(), it will invoke
commit from this
managedConnection. If this variable already associated with a connection when you called
begin(), it will raise a