Return-Path: Delivered-To: apmail-incubator-open-jpa-dev-archive@locus.apache.org Received: (qmail 70516 invoked from network); 28 Feb 2007 21:48:39 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 28 Feb 2007 21:48:39 -0000 Received: (qmail 86114 invoked by uid 500); 28 Feb 2007 21:48:47 -0000 Delivered-To: apmail-incubator-open-jpa-dev-archive@incubator.apache.org Received: (qmail 86091 invoked by uid 500); 28 Feb 2007 21:48:47 -0000 Mailing-List: contact open-jpa-dev-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: open-jpa-dev@incubator.apache.org Delivered-To: mailing list open-jpa-dev@incubator.apache.org Received: (qmail 86082 invoked by uid 99); 28 Feb 2007 21:48:47 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 28 Feb 2007 13:48:47 -0800 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (herse.apache.org: domain of ppoddar@bea.com designates 66.248.192.22 as permitted sender) Received: from [66.248.192.22] (HELO usremg02.bea.com) (66.248.192.22) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 28 Feb 2007 13:48:36 -0800 Received: from usremr02.bea.com (mailrelay.bea.com [10.160.29.92]) by usremg02.bea.com (Switch-3.2.2/Switch-3.2.2) with ESMTP id l1SLmLOw022609 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL) for ; Wed, 28 Feb 2007 13:48:22 -0800 Received: from repbex01.amer.bea.com (repbex01.bea.com [10.160.26.98]) by usremr02.bea.com (Switch-3.2.2/Switch-3.2.2) with ESMTP id l1SLmDLW026909 for ; Wed, 28 Feb 2007 13:48:13 -0800 X-MimeOLE: Produced By Microsoft Exchange V6.5 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Subject: RE: EMF JNDI lookup is starting openJPA every time - was: Howto integrate JPA within EJB2.1 session beans? Date: Wed, 28 Feb 2007 13:48:00 -0800 Message-ID: <5C219175D559A64D8C2CC65E41D36856D39A8E@repbex01.amer.bea.com> In-Reply-To: <001f01c75b01$dd393fc0$0500a8c0@burns> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: EMF JNDI lookup is starting openJPA every time - was: Howto integrate JPA within EJB2.1 session beans? Thread-Index: AcdWfiNDvpWkP1tPRUSi1Cw5UP7aZQAIO4NQAAwuLVAAKIS60AAAKNJgAEzrqwAAZflq8AAWNbgQABj/ebAAAIdsIAABJCZAAB/cL7A= References: <7D856CDFE035FF45A0420ACBD71BDD6303592DDE@repbex02.amer.bea.com> <001f01c75b01$dd393fc0$0500a8c0@burns> From: "Pinaki Poddar" To: X-PMX-Version: 4.7.1.128075, Antispam-Engine: 2.5.0.283055, Antispam-Data: 2007.2.21.151434 X-Virus-Checked: Checked by ClamAV on apache.org > EntityManagerFactory emf =3D OpenJPAPersistence.createEntityManagerFactory(EMF_JNDI_LOCATION, (Context) null); 1. Instead of passing null context, if the same Context instance is passed on every invocation -- does the behaviour change? 2. If the emf and its underlying brokerfactory bf from two consecutive invocation are emf1,bf1 and emf2, bf2 then which of the following are true? a) emf1 =3D=3D emf2 and bf1 =3D=3D bf2 b). emf1 !=3D emf2 but bf1 =3D=3D bf2 c). emf1!=3Demf2 and bf1!=3Dbf2 Pinaki Poddar BEA Systems 415.402.7317=20=20 -----Original Message----- From: Hans J. Prueller [mailto:hans.prueller@gmx.net]=20 Sent: Tuesday, February 27, 2007 10:30 PM To: open-jpa-dev@incubator.apache.org Subject: AW: EMF JNDI lookup is starting openJPA every time - was: Howto integrate JPA within EJB2.1 session beans?=20 please see below. The method PersistenceService.getEntityManager() is invoked directly in SLSB's methods if access to the EM is needed, so there could be multiple invocations within a single transaction spanning multiple SLSB methods. hth, Hans public class PersistenceService { private static final Logger logger =3D Logger.getLogger(PersistenceService.class.getName()); =09 public static final String EMF_JNDI_LOCATION =3D "your/EMF/JNDI/location"; public static EntityManager getEntityManager() { =09=09 logger.log(Level.FINEST, "creating a fresh, clean EntityManager from JNDI EMF."); =09=09 EntityManagerFactory emf =3D OpenJPAPersistence =09 .createEntityManagerFactory(EMF_JNDI_LOCATION, (Context) null); final BrokerFactory bf =3D OpenJPAPersistence.toBrokerFactory(emf); final Broker b =3D bf.newBroker(bf.getConfiguration() .getConnectionUserName(), bf.getConfiguration() .getConnectionPassword(), true, bf.getConfiguration().getConnectionRetainModeConstant(), true);=20 // do some JPA configuration setup. Logic stolen from=20 // EntityManagerFactoryImpl. b.setAutoDetach(AutoDetach.DETACH_CLOSE, true); b.setAutoDetach(AutoDetach.DETACH_ROLLBACK, true); b.setDetachedNew(false); return OpenJPAPersistence.toEntityManager(b); } } _______________________________________________________________________ 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.