Hi,
> connection being thrown away after I finish a transaction and close the
> EntityManager.
ConnectionRetainMode 'always' retains the connection *until* the
EntityManager closes. Once you close the EntityManager, the connection will
return to the pool for obvious reasons.
The following test passes on ConnectionRetainMode='always'
public void testRetain() {
EntityManager em = getEM();
em.getTransaction().begin();
em.persist(new PObject());
Object con = OpenJPAPersistence.cast(em).getConnection();
em.getTransaction().commit();
for (int i=0; i<10; i++) {
em.getTransaction().begin();
em.persist(new PObject());
Object con2 =
OpenJPAPersistence.cast(em).getConnection();
assertEquals(con, con2);
em.getTransaction().commit();
}
}
--
View this message in context:
http://n2.nabble.com/Does-ConnectionRetainMode-do-anything--tp471015p471550.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.