openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Patrick Linskey" <plins...@bea.com>
Subject RE: WARNING: Connection not closed by caller - messages producedbyOpenJPA?
Date Wed, 28 Mar 2007 19:43:58 GMT
What happens if you set 'openjpa.TransactionMode' to 'managed' as well?

Also, are you closing your EMs at the end of the transaction?

-Patrick

-- 
Patrick Linskey
BEA Systems, Inc. 

_______________________________________________________________________
Notice:  This email message, together with any attachments, may contain
information  of  BEA Systems,  Inc.,  its subsidiaries  and  affiliated
entities,  that may be confidential,  proprietary,  copyrighted  and/or
legally privileged, and is intended solely for the use of the individual
or entity named in this message. If you are not the intended recipient,
and have received this message in error, please immediately return this
by email and then delete it. 

> -----Original Message-----
> From: Hans J. Prueller [mailto:hans.prueller@gmx.net] 
> Sent: Wednesday, March 28, 2007 12:14 PM
> To: open-jpa-dev@incubator.apache.org
> Subject: RE: WARNING: Connection not closed by caller - 
> messages producedbyOpenJPA?
> 
> The usage case of the EM is, that I call a 
> PersistenceService.getEntityManager() method in every method 
> of my SLSB's, the SLSBs all have
> the "Required" attribute set for TXs, so every time I call 
> the getEM() method, there should be an already running JTA TX. 
> 
> This is the code:
> 
> 
> logger.log(Level.FINEST,
> "creating a fresh, clean EntityManager from JNDI EMF.");
> 
> // EntityManagerFactory emf = OpenJPAPersistence
> // .createEntityManagerFactory(EMF_JNDI_LOCATION, (Context) null);
> 
> final EntityManagerFactory emf = getEMF();
> 
> final BrokerFactory bf = OpenJPAPersistence.toBrokerFactory(emf);
> 
> final Broker b = bf.newBroker(bf.getConfiguration()
> .getConnectionUserName(), bf.getConfiguration()
> .getConnectionPassword(), true, // the broker is part of a 
> JTA  managed tx
> bf.getConfiguration().getConnectionRetainModeConstant(), 
> true); // look for an existing Broker on the tx
> 
> // do some JPA configuration setup. Logic stolen from
> // EntityManagerFactoryImpl.
> b.setAutoDetach(AutoDetach.DETACH_CLOSE, true);
> b.setAutoDetach(AutoDetach.DETACH_ROLLBACK, true);
> b.setDetachedNew(false);
> 
> return OpenJPAPersistence.toEntityManager(b);
> 
> 
> And here you have the persistence.xml:
> 
> <persistence-unit name="lbsims" transaction-type="JTA">
> <provider>
> org.apache.openjpa.persistence.PersistenceProviderImpl
> </provider>
> <jta-data-source>jdbc_lbsims</jta-data-source>
> <properties>
> <property name="openjpa.ConnectionFactoryMode"
> value="managed" />
> <property name="openjpa.ManagedRuntime"
> value="jndi(TransactionManagerName=java:comp/UserTransaction)" />
> <property name="openjpa.DataCache" value="true"/>
> <property name="openjpa.RemoteCommitProvider" value="sjvm"/> 
> </properties>
> </persistence-unit>
> 
> hth,
> HANS
> 
> 
> 
> Am Mittwoch, den 28.03.2007, 11:54 -0700 schrieb Patrick Linskey: 
> 
> 	
> 	Also, how are you integrating it with the JTA 
> transaction? Are you
> 	calling EM.joinTransaction(), or ensuring that the 
> transaction is in
> 	progress before creating the EM, or something else?
> 	
> 	-Patrick
> 	
> 
> 

Notice:  This email message, together with any attachments, may contain information  of  BEA
Systems,  Inc.,  its subsidiaries  and  affiliated entities,  that may be confidential,  proprietary,
 copyrighted  and/or legally privileged, and is intended solely for the use of the individual
or entity named in this message. If you are not the intended recipient, and have received
this message in error, please immediately return this by email and then delete it.

Mime
View raw message