openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dain Sundstrom <>
Subject Can I reuse instances?
Date Sun, 08 Apr 2007 07:17:51 GMT
Is it possible to reuse instances from transaction to transaction?

I would like to be able to create a bean in one transaction, detach  
it and reattach the same instance in a new transaction.  My goal here  
is specifically to reuse instances across transactions because they  
have a very expensive creation cost, and no I can not redesign the  

I tried a quick test case using merge, but merge returned a new  

         Employee dain = entityManager.find(Employee.class, dainPk);
         assertEquals(dain.getFirstName(), "Dain");

         assertSame(dain, entityManager.merge(dain));
         assertEquals(david.getFirstName(), "Dain");

When I try to use the refresh method, OpenJPA complains that the  
entity "is not managed by this context".

So is there anyway for me to reuse instances?


View raw message