Return-Path: Delivered-To: apmail-incubator-open-jpa-dev-archive@locus.apache.org Received: (qmail 37318 invoked from network); 27 Feb 2007 17:16:37 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 27 Feb 2007 17:16:37 -0000 Received: (qmail 87294 invoked by uid 500); 27 Feb 2007 17:16:45 -0000 Delivered-To: apmail-incubator-open-jpa-dev-archive@incubator.apache.org Received: (qmail 87268 invoked by uid 500); 27 Feb 2007 17:16:45 -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 87259 invoked by uid 99); 27 Feb 2007 17:16:45 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 27 Feb 2007 09:16:45 -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 plinskey@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; Tue, 27 Feb 2007 09:16:34 -0800 Received: from usremr01.bea.com (usremr01.bea.com [10.160.29.91]) by usremg02.bea.com (Switch-3.2.2/Switch-3.2.2) with ESMTP id l1RHGCYU025696 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL) for ; Tue, 27 Feb 2007 09:16:12 -0800 Received: from repbex02.amer.bea.com (repbex02.bea.com [10.160.26.99]) by usremr01.bea.com (Switch-3.2.2/Switch-3.2.2) with ESMTP id l1RHGAKA013918 for ; Tue, 27 Feb 2007 09:16:11 -0800 X-MimeOLE: Produced By Microsoft Exchange V6.5 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Subject: RE: RE: EMF JNDI lookup is starting openJPA every time - was: Howto integrate JPA within EJB2.1 session beans? Date: Tue, 27 Feb 2007 09:16:10 -0800 Message-ID: <7D856CDFE035FF45A0420ACBD71BDD6303592A70@repbex02.amer.bea.com> In-Reply-To: <20070227121015.221480@gmx.net> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: RE: EMF JNDI lookup is starting openJPA every time - was: Howto integrate JPA within EJB2.1 session beans? Thread-Index: AcdaaFPQ9EToFKcdQoWU888TAaze1wAKYq0g References: <7D856CDFE035FF45A0420ACBD71BDD63034FE0F7@repbex02.amer.bea.com> <001001c758a7$41a31ce0$0500a8c0@burns> <7D856CDFE035FF45A0420ACBD71BDD63035929BF@repbex02.amer.bea.com> <20070227121015.221480@gmx.net> From: "Patrick Linskey" To: X-PMX-Version: 4.7.1.128075, Antispam-Engine: 2.5.0.283055, Antispam-Data: 2007.2.21.161433 X-Virus-Checked: Checked by ClamAV on apache.org > Would it be helpful if I provide the output of=20 > "Thread.dumpStack()" within > the invocation of my PersistenceService.getEntityManager() method? No -- that'll just provide info about your environment. But looking at = your logs in more detail, I'm curious about what your PersistenceService = method does. Could you post the full declaration of the method, and how = you're invoking it? -Patrick --=20 Patrick Linskey BEA Systems, Inc.=20 _______________________________________________________________________ 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.=20 > -----Original Message----- > From: Hans Prueller [mailto:hans.prueller@gmx.net]=20 > Sent: Tuesday, February 27, 2007 4:10 AM > To: open-jpa-dev@incubator.apache.org;=20 > open-jpa-dev@incubator.apache.org > Subject: Re: RE: EMF JNDI lookup is starting openJPA every=20 > time - was: Howto integrate JPA within EJB2.1 session beans? >=20 > strange.=20 >=20 > When I look on the code it seems that it definitely could NOT=20 > be the case that the EMF is not correctly bound to the JNDI=20 > tree as the method OpenJPAEntityManagerFactory=20 > createEntityManagerFactory does no create for itself.=20 > So somehow the EMF must be bound to the JNDI tree but=20 > nevertheless I can see the init-logmessages evertime I access=20 > it from JNDI... >=20 > I will try to provide more detailed information. >=20 > Would it be helpful if I provide the output of=20 > "Thread.dumpStack()" within > the invocation of my PersistenceService.getEntityManager() method? >=20 > regards, > hans >=20 >=20 > -------- Original-Nachricht -------- > Datum: Mon, 26 Feb 2007 23:10:42 -0800 > Von: "Patrick Linskey" > An: open-jpa-dev@incubator.apache.org > CC:=20 > Betreff: RE: EMF JNDI lookup is starting openJPA every time -=20 > was: Howto integrate JPA within EJB2.1 session beans? >=20 > > It should be going through the following code: > >=20 > > public static OpenJPAEntityManagerFactory=20 > createEntityManagerFactory > > (String jndiLocation, Context context) { > > if (jndiLocation =3D=3D null) > > throw new NullPointerException("jndiLocation =3D=3D = null"); > >=20 > > try { > > if (context =3D=3D null) > > context =3D new InitialContext(); > >=20 > > Object o =3D context.lookup(jndiLocation); > > return (OpenJPAEntityManagerFactory) > > PortableRemoteObject.narrow(o, > > OpenJPAEntityManagerFactory.class); > > } catch (NamingException ne) { > > throw new ArgumentException(_loc.get("naming-exception", > > jndiLocation), new Throwable[]{ ne }, null, true); > > } > > } > >=20 > > I don't see anything in there that would be causing a=20 > creation to happen. > > But maybe something funky is happening with JNDI=20 > serializing the factory > > and then deserializing it or something. > >=20 > > Do you have any means of getting a stack from where the creation is > > happening? It'd be great to get a bit more context about=20 > what's going on. > >=20 > > -Patrick > >=20 > > --=20 > > Patrick Linskey > > BEA Systems, Inc.=20 > >=20 > >=20 > ______________________________________________________________ > _________ > > Notice: This email message, together with any attachments,=20 > may contain > > information of BEA Systems, Inc., its subsidiaries and=20 > affiliated > > entities, that may be confidential, proprietary, =20 > copyrighted and/or > > legally privileged, and is intended solely for the use of=20 > the individual > > or entity named in this message. If you are not the=20 > intended recipient, > > and have received this message in error, please immediately=20 > return this > > by email and then delete it.=20 > >=20 > > > -----Original Message----- > > > From: Hans J. Prueller [mailto:hans.prueller@gmx.net]=20 > > > Sent: Saturday, February 24, 2007 10:36 PM > > > To: open-jpa-dev@incubator.apache.org > > > Subject: EMF JNDI lookup is starting openJPA every time -=20 > > > was: Howto integrate JPA within EJB2.1 session beans?=20 > > >=20 > > > Hi together, Patrick, > > >=20 > > > the code you suggested for doing a helper method that deals=20 > > > with the EMF > > > JNDI lookup and the EM creating within our J2EE1.4 app=20 > > > basically works fine, > > > but as you perhaps may remember I asked why the method is=20 > > > called "create": > > >=20 > > > EntityManagerFactory myemf =3D > > > OpenJPAPersistence.createEntityManagerFactory(strJNDILocation, > > > (Context)null); > > >=20 > > > It seems that the method above really creates a NEW EMF on=20 > > > every invocation! > > > I checked the logs of my application and I see the following=20 > > > messages on > > > every invocation of my PersistenceService.getEntityManger()=20 > > > method (which > > > does the above lookup and some more ..) > > >=20 > > > 2007-02-25 07:27:05,687 : PersistenceService.getEntityManager=20 > > > : creating a > > > fresh > > > , clean EntityManager from JNDI EMF. > > > 15 lbsims INFO [RMI TCP Connection(35)-192.168.0.5]=20 > > > openjpa.Runtime - > > > Starti > > > ng OpenJPA 0.9.7-incubating-SNAPSHOT > > > 15 lbsims INFO [RMI TCP Connection(35)-192.168.0.5]=20 > > > openjpa.jdbc.JDBC - > > > Open > > > JPA will now connect to the database to attempt to determine=20 > > > what type of > > > databa > > > se dictionary to use. To prevent this connection in the=20 > > > future, set your > > > openjp > > > a.jdbc.DBDictionary configuration property to the appropriate=20 > > > value for your > > > dat > > > abase (see the documentation for available values). > > > 15 lbsims INFO [RMI TCP Connection(35)-192.168.0.5]=20 > > > openjpa.jdbc.JDBC - > > > Usin > > > g dictionary class=20 > > > "org.apache.openjpa.jdbc.sql.MySQLDictionary" (MySQL > > > 5.0.27-c > > > ommunity-nt ,MySQL-AB JDBC Driver=20 > mysql-connector-java-5.0.4 ( $Date: > > > 2006-10-19 > > > 17:47:48 +0200 (Thu, 19 Oct 2006) $, $Revision: 5908 $ )). > > > 15 lbsims INFO [RMI TCP Connection(35)-192.168.0.5]=20 > > > openjpa.MetaData - > > > Found > > > 1 classes with metadata in 0 milliseconds. > > >=20 > > >=20 > > > It seems that OpenJPA is now bootstrapping everytime I=20 > access it. I am > > > binding the EMF somewhen at bootstrapping time with > > >=20 > > > final EntityManagerFactory emFactory =3D Persistence > > > .createEntityManagerFactory("lbsims"); > > >=20 > > > Context ictx =3D new InitialContext(); > > > ictx.bind(PersistenceService.EMF_JNDI_LOCATION, emFactory); > > >=20 > > > The lookup uses the same constants, so the EMF in JNDI should=20 > > > be found? > > >=20 > > > EntityManagerFactory emf =3D OpenJPAPersistence > > > =09 > > > .createEntityManagerFactory(EMF_JNDI_LOCATION, (Context) null); > > >=20 > > > Any Idea what could be wrong here? > > >=20 > > > regards, > > > HANS > > >=20 > > >=20 > > > > -----Urspr=FCngliche Nachricht----- > > > > Von: Patrick Linskey [mailto:plinskey@bea.com] > > > > Gesendet: Freitag, 23. Februar 2007 18:46 > > > > An: open-jpa-dev@incubator.apache.org > > > > Betreff: RE: TYPO? Howto integrate JPA within EJB2.1=20 > session beans? > > > > [architecture] > > > >=20 > > > > Typo indeed. It should be=20 > > > OpenJPAPersistence.toBrokerFactory(emf). Sorry > > > > about that. > > > >=20 > > > > -Patrick > > > >=20 > > > > -- > > > > Patrick Linskey > > > > BEA Systems, Inc. > > > >=20 > > > >=20 > > > ______________________________________________________________ > > > _________ > > > > Notice: This email message, together with any attachments,=20 > > > may contain > > > > information of BEA Systems, Inc., its subsidiaries and=20 > > > affiliated > > > > entities, that may be confidential, proprietary, =20 > > > copyrighted and/or > > > > legally privileged, and is intended solely for the use of=20 > > > the individual > > > > or entity named in this message. If you are not the=20 > > > intended recipient, > > > > and have received this message in error, please immediately=20 > > > return this > > > > by email and then delete it. > > > >=20 > > > > > -----Original Message----- > > > > > From: Hans J. Prueller [mailto:hans.prueller@gmx.net] > > > > > Sent: Friday, February 23, 2007 9:43 AM > > > > > To: open-jpa-dev@incubator.apache.org > > > > > Subject: RE: TYPO? Howto integrate JPA within EJB2.1 session > > > > > beans? [architecture] > > > > > > > > > > Patrick, > > > > > > > > > > I'm currently trying your tip with a PersistenceService util > > > > > class doing > > > > > the lookup of a synchronized entity manager. The problem is > > > > > that your sample > > > > > code does not work! > > > > > > > > > > in fact the statement > > > > > > > > > > final BrokerFactory bf =3D OpenJPAPersistence.cast(emf); > > > > > > > > > > is the problem. the above "cast" does not return a > > > > > BrokerFactory instance! > > > > > > > > > > I am using a 2 days old nightly snapshot 0.9.7 build > > > > > > > > > > Where is the problem? > > > > > > > > > > Hans > > > > > > > > > > > -----Urspr=FCngliche Nachricht----- > > > > > > Von: Patrick Linskey [mailto:plinskey@bea.com] > > > > > > Gesendet: Donnerstag, 22. Februar 2007 23:22 > > > > > > An: open-jpa-dev@incubator.apache.org > > > > > > Betreff: RE: RE: Howto integrate JPA within EJB2.1=20 > > > session beans? > > > > > > [architecture] > > > > > > > > > > > > > Unfortunately, that means that we're using a synchronized > > > > > > > block during the lookup. If it looks like EM lookup is a > > > > > > > scalability issue for your app, do let us know -- it would > > > > > > > be pretty straightforward to replace the=20 > synchronized block > > > > > > > with a concurrent map. > > > > > > > > > > > > OK, I got fed up with that synchronized block. OPENJPA-161 > > > > > tracks the > > > > > > issue; I've got a patch that I'll submit once some more > > > > > eyes look at it. > > > > > > > > > > > > -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: Patrick Linskey [mailto:plinskey@bea.com] > > > > > > > Sent: Thursday, February 22, 2007 8:38 AM > > > > > > > To: open-jpa-dev@incubator.apache.org > > > > > > > Subject: RE: RE: Howto integrate JPA within EJB2.1 session > > > > > > > beans? [architecture] > > > > > > > > > > > > > > > If I understand it correct, I "just" have to=20 > bind the EMF > > > > > > > > onserver startup like. > > > > > > > > > > > > > > > > context.bind("my/jndi/name/for/emf",myEMFVariable); > > > > > > > > > > > > > > Yep. > > > > > > > > > > > > > > > //does the statement below again create=20 > a NEW EMF > > > > > > > or ist this > > > > > > > > //just a lookup in the jndi-tree? but why is it > > > > > > > > called "Create" > > > > > > > > //and not get? > > > > > > > > EntityManagerFactory emf =3D OpenJPAPersistence > > > > > > > > .createEntityManagerFactory( > > > > > > > > "your/EMF/JNDI/location",=20 > (Context) null); > > > > > > > > > > > > > > It's just a lookup. I'm not sure why it's called=20 > > > 'create'. Anyone? > > > > > > > > > > > > > > > //why do I have to create a new > > > > > > > broker/entitymanager this way? > > > > > > > > //is this because I have to=20 > "synchronize" the SLSBs > > > > > > > > transaction > > > > > > > > //context with the newly created entitymanager? > > > > > > > > > > > > > > Yes -- our current OpenJPAPersistence EM lookup methods > > > > > all create new > > > > > > > EMs. The broker code will look up one associated with=20 > > > the current > > > > > > > transaction, which is what you're looking for. > > > > > > > > > > > > > > Unfortunately, that means that we're using a synchronized > > > > > block during > > > > > > > the lookup. If it looks like EM lookup is a scalability > > > > > issue for your > > > > > > > app, do let us know -- it would be pretty=20 > straightforward to > > > > > > > replace the > > > > > > > synchronized block with a concurrent map. > > > > > > > > > > > > > > > So if understand that right I just would have to call > > > > > > > > > > > > > > > > PersistenceService.getEntitymanager(); > > > > > > > > > > > > > > > > in every SLSB method (NOT in ejbCreate) when=20 > needed? fine. > > > > > > > > > > > > > > Yep. > > > > > > > > > > > > > > > I really appreciate your help - it's quite complex=20 > > > to integrate > > > > > > > > JPA into an existing Java2EE 1.4 AppServer=20 > > > environment.. *puh* > > > > > > > > > > > > > > Yes -- sorry about that. We should at least be creating > > > > > > > better-designed > > > > > > > helper methods in OpenJPA to help out with this. > > > > > > > > > > > > > > One alternative, of course, is to use Spring 2,=20 > which does a > > > > > > > pretty good > > > > > > > job of JPA bootstrapping. > > > > > > > > > > > > > > -Patrick > > > > > > > > > > > > > > -- > > > > > > > Patrick Linskey > > > > > > > BEA Systems, Inc. > > > > > > > > > > > > > >=20 > ______________________________________________________________ > > > > > > > _________ > > > > > > > Notice: This email message, together with any=20 > attachments, > > > > > > > may contain > > > > > > > information of BEA Systems, Inc., its=20 > subsidiaries and > > > > > > > affiliated > > > > > > > entities, that may be confidential, proprietary, > > > > > > > copyrighted and/or > > > > > > > legally privileged, and is intended solely for=20 > the use of the > > > > > > > individual > > > > > > > or entity named in this message. If you are not=20 > the intended > > > > > > > recipient, > > > > > > > and have received this message in error, please=20 > immediately > > > > > > > return this > > > > > > > by email and then delete it. > > > > > > > > > > > > > > > -----Original Message----- > > > > > > > > From: Hans Prueller [mailto:hans.prueller@gmx.net] > > > > > > > > Sent: Thursday, February 22, 2007 4:36 AM > > > > > > > > To: open-jpa-dev@incubator.apache.org; > > > > > > > > open-jpa-dev@incubator.apache.org > > > > > > > > Subject: Re: RE: Howto integrate JPA within=20 > EJB2.1 session > > > > > > > > beans? [architecture] > > > > > > > > > > > > > > > > Patrick, > > > > > > > > > > > > > > > > thank you for that tip. To be true, I was not aware of > > > > > > > > lifecycle related problems between my SLSBs and=20 > JPA - thank > > > > > > > > you for that hint. As I want to avoid working with > > > > > > > > ThreadLocal (simply because I didn't work with=20 > ThreadLocals > > > > > > > > yet) I would prefer the JNDI-EMF based approach. > > > > > > > > > > > > > > > > If I understand it correct, I "just" have to=20 > bind the EMF > > > > > > > > onserver startup like. > > > > > > > > > > > > > > > > context.bind("my/jndi/name/for/emf",myEMFVariable); > > > > > > > > > > > > > > > > I would be interested what the code for the > > > > > > > > PersistenceService class does: > > > > > > > > > > > > > > > > > > > > > > > > //does the statement below again create=20 > a NEW EMF > > > > > > > or ist this > > > > > > > > //just a lookup in the jndi-tree? but why is it > > > > > > > > called "Create" > > > > > > > > //and not get? > > > > > > > > EntityManagerFactory emf =3D OpenJPAPersistence > > > > > > > > .createEntityManagerFactory( > > > > > > > > "your/EMF/JNDI/location",=20 > (Context) null); > > > > > > > > > > > > > > > > //why do i have to cast the EMF to a > > > > > brokerfactory now? I > > > > > > > > //would guess the "broker" is something like a > > > > > more abstract > > > > > > > > //concept of entitymanager(factory)? > > > > > > > > > > > > > > > > //why do I have to create a new > > > > > > > broker/entitymanager this way? > > > > > > > > //is this because I have to=20 > "synchronize" the SLSBs > > > > > > > > transaction > > > > > > > > //context with the newly created entitymanager? > > > > > > > > > > > > > > > > BrokerFactory bf =3D = OpenJPAPersistence.cast(emf); > > > > > > > > Broker b =3D bf.newBroker( > > > > > > > > bf.getConfiguration().getConnectionUserName(), > > > > > > > > bf.getConfiguration().getConnectionPassword(), > > > > > > > > true, // the broker is part of a JTA=20 > managed tx > > > > > > > > > > > > > bf.getConfiguration().getConnectionRetainModeConstant(), > > > > > > > > true); // look for an existing Broker=20 > on the tx > > > > > > > > > > > > > > > > =20 > broker.setAutoDetach(AutoDetach.DETACH_CLOSE, true); > > > > > > > > =20 > > > broker.setAutoDetach(AutoDetach.DETACH_ROLLBACK, true); > > > > > > > > broker.setDetachedNew(false); > > > > > > > > > > > > > > > > return OpenJPAPersistence.toEntityManager(b); > > > > > > > > } > > > > > > > > > > > > > > > > So if understand that right I just would have to call > > > > > > > > > > > > > > > > PersistenceService.getEntitymanager(); > > > > > > > > > > > > > > > > in every SLSB method (NOT in ejbCreate) when=20 > needed? fine. I > > > > > > > > really appreciate your help - it's quite complex to=20 > > > integrate > > > > > > > > JPA into an existing Java2EE 1.4 AppServer=20 > > > environment.. *puh* > > > > > > > > > > > > > > > > regards > > > > > > > > Hans > > > > > > > > > > > > > > > > -------- Original-Nachricht -------- > > > > > > > > Datum: Wed, 21 Feb 2007 08:43:20 -0800 > > > > > > > > Von: "Patrick Linskey" > > > > > > > > An: open-jpa-dev@incubator.apache.org > > > > > > > > CC: > > > > > > > > Betreff: RE: Howto integrate JPA within EJB2.1=20 > > > session beans? > > > > > > > > [architecture] > > > > > > > > > > > > > > > > > Another common technique is to get an EMF into=20 > > > JNDI, either > > > > > > > > by using a > > > > > > > > > startup hook or deploying OpenJPA as a JCA RAR. > > > > > > > > > > > > > > > > > > Are you looking to integrate OpenJPA with your=20 > > > current managed > > > > > > > > > transaction? If so, I'd be careful about=20 > creating an EM in > > > > > > > > ejbCreate(), > > > > > > > > > as its lifecycle is related to the life of the SLSB, > > > > > not to the > > > > > > > > > transactional context (the SLSB might be=20 > pooled). So, I'd > > > > > > > > just try to > > > > > > > > > get the EMF into JNDI when the server starts=20 > > > (creating EMFs > > > > > > > > is slow). > > > > > > > > > Then, you could avoid having to use your own=20 > ThreadLocal > > > > > > > > work by using > > > > > > > > > the internal OpenJPA BrokerFactory APIs: > > > > > > > > > > > > > > > > > > public class PersistenceService { > > > > > > > > > public static EntityManager getEntityManager() { > > > > > > > > > EntityManagerFactory emf =3D = OpenJPAPersistence > > > > > > > > > .createEntityManagerFactory( > > > > > > > > > "your/EMF/JNDI/location",=20 > (Context) null); > > > > > > > > > BrokerFactory bf =3D=20 > OpenJPAPersistence.cast(emf); > > > > > > > > > Broker b =3D bf.newBroker( > > > > > > > > > =20 > bf.getConfiguration().getConnectionUserName(), > > > > > > > > > =20 > bf.getConfiguration().getConnectionPassword(), > > > > > > > > > true, // the broker is part of a JTA=20 > > > managed tx > > > > > > > > > > > > > > > > bf.getConfiguration().getConnectionRetainModeConstant(), > > > > > > > > > true); // look for an existing Broker=20 > > > on the tx > > > > > > > > > > > > > > > > > > // do some JPA configuration setup. Logic=20 > > > stolen from > > > > > > > > > // EntityManagerFactoryImpl. > > > > > > > > > =20 > > > broker.setAutoDetach(AutoDetach.DETACH_CLOSE, true); > > > > > > > > > > > > > > broker.setAutoDetach(AutoDetach.DETACH_ROLLBACK, true); > > > > > > > > > broker.setDetachedNew(false); > > > > > > > > > > > > > > > > > > return OpenJPAPersistence.toEntityManager(b); > > > > > > > > > } > > > > > > > > > } > > > > > > > > > > > > > > > > > > Meanwhile, we really should add a couple new > > > > > OpenJPAPersistence / > > > > > > > > > OpenJPAEntityManagerFactory methods to help out with > > > > > this type of > > > > > > > > > bootstrapping. > > > > > > > > > > > > > > > > > > -Patrick > > > > > > > > > > > > > > > > > > -- > > > > > > > > > Patrick Linskey > > > > > > > > > BEA Systems, Inc. > > > > > > > > > > > > > > > > > > > > > > > > > >=20 > > > ______________________________________________________________ > > > > > > > > _________ > > > > > > > > > Notice: This email message, together with any=20 > > > attachments, > > > > > > > > may contain > > > > > > > > > information of BEA Systems, Inc., its=20 > > > subsidiaries and > > > > > > > > affiliated > > > > > > > > > entities, that may be confidential, proprietary, > > > > > > > > copyrighted and/or > > > > > > > > > legally privileged, and is intended solely=20 > 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=20 > > > immediately > > > > > > > > return this > > > > > > > > > by email and then delete it. > > > > > > > > > > > > > > > > > > > -----Original Message----- > > > > > > > > > > From: Hans Prueller [mailto:hans.prueller@gmx.net] > > > > > > > > > > Sent: Wednesday, February 21, 2007 1:02 AM > > > > > > > > > > To: open-jpa-dev@incubator.apache.org > > > > > > > > > > Subject: Howto integrate JPA within EJB2.1=20 > > > session beans? > > > > > > > > > > [architecture] > > > > > > > > > > > > > > > > > > > > Hi together, > > > > > > > > > > > > > > > > > > > > I'm sorry for bothering you with numerous basic=20 > > > questions > > > > > > > > > > regarding OpenJPA and its usage but I have=20 > to migrate > > > > > > > > > > existing CMP EJBs to migrate within short time=20 > > > to OpenJPA as > > > > > > > > > > we're having stability issues with the current=20 > > > CMP engine. > > > > > > > > > > > > > > > > > > > > One last question I'd like to ask is regarding the > > > > > > > > > > recommended architecture of using OpenJPA=20 > within EJB2.1 > > > > > > > > > > Stateless sessino beans: > > > > > > > > > > > > > > > > > > > > I need to work with persistence i.e. the=20 > EntityManager > > > > > > > > > > throughout all the session beans methods so my=20 > > > idea is to: > > > > > > > > > > > > > > > > > > > > - create a EntityManagerFactory in the=20 > > > ejbCreate() method > > > > > > > > of the SLSB > > > > > > > > > > - and also create the EntityManager itself in the > > > > > > > > > > ejbCreeate() method and store it as a=20 > member variable > > > > > > > of the SLSB > > > > > > > > > > - this would allow easy access within the SB's=20 > > > methods by > > > > > > > > > > just using the already initialized entity=20 > > > manager varialbe > > > > > > > > > > em.createNamedQuery() .. etc. etc. > > > > > > > > > > - clean up should be performed in the=20 > ejbRemove() method > > > > > > > > of the SLSB > > > > > > > > > > > > > > > > > > > > I think doing so will allow migratino to=20 > > > openJPA with less > > > > > > > > > > work than doing the whole lookup procedure in=20 > > > every method > > > > > > > > > > separately. > > > > > > > > > > > > > > > > > > > > what do you think? are there any pitfalls i've=20 > > > overlooked? > > > > > > > > > > > > > > > > > > > > thank you for your ideas! > > > > > > > > > > > > > > > > > > > > regards > > > > > > > > > > Hans > > > > > > > > > > -- > > > > > > > > > > "Feel free" - 5 GB Mailbox, 50 FreeSMS/Monat ... > > > > > > > > > > Jetzt GMX ProMail testen: > > > > > > > www.gmx.net/de/go/mailfooter/promail-out > > > > > > > > > > > > > > > > > > > > > > > > > > -- > > > > > > > > "Feel free" - 5 GB Mailbox, 50 FreeSMS/Monat ... > > > > > > > > Jetzt GMX ProMail testen: > > > > > www.gmx.net/de/go/mailfooter/promail-out > > > > > > > > > > > > > > > > > > > > > > > > > > > >=20 > > >=20 >=20 > --=20 > "Feel free" - 5 GB Mailbox, 50 FreeSMS/Monat ... > Jetzt GMX ProMail testen: www.gmx.net/de/go/mailfooter/promail-out >=20