Return-Path: Delivered-To: apmail-incubator-open-jpa-dev-archive@locus.apache.org Received: (qmail 59387 invoked from network); 21 Feb 2007 16:01:20 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 21 Feb 2007 16:01:20 -0000 Received: (qmail 34675 invoked by uid 500); 21 Feb 2007 16:01:28 -0000 Delivered-To: apmail-incubator-open-jpa-dev-archive@incubator.apache.org Received: (qmail 34654 invoked by uid 500); 21 Feb 2007 16:01:28 -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 34645 invoked by uid 99); 21 Feb 2007 16:01:28 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 21 Feb 2007 08:01:28 -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, 21 Feb 2007 08:01:17 -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 l1LG0thA026973 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL) for ; Wed, 21 Feb 2007 08:00:55 -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 l1LG0nvf032171 for ; Wed, 21 Feb 2007 08:00:53 -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: Howto integrate JPA within EJB2.1 session beans? [architecture] Date: Wed, 21 Feb 2007 07:57:48 -0800 Message-ID: <5C219175D559A64D8C2CC65E41D36856C8AD0D@repbex01.amer.bea.com> In-Reply-To: <20070221090211.252440@gmx.net> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: Howto integrate JPA within EJB2.1 session beans? [architecture] Thread-Index: AcdVlwzNtAwOCTRUTamUlvmhs13cKAAOHMTw References: <20070221090211.252440@gmx.net> From: "Pinaki Poddar" To: X-PMX-Version: 4.7.1.128075, Antispam-Engine: 2.5.0.283055, Antispam-Data: 2007.2.21.51933 X-Virus-Checked: Checked by ClamAV on apache.org One way to provide acccess to EntityManagerFactory/EntityManager to the SLSB is to collate JPA-related facilities into a separate class (say PersistenceService). PersistenceService will a) ensure EntityManagerFactory is created once (or at least not too often) as that is the 'heavy' operation b) provide EntityManager either i) by creating a new one in every call and/or ii) providing an existing EntityManager bound to the current thread (using ThreadLocal, for example) to emulate a session-per-thread model. This session-per-thread is useful when one bean calling another within the same transaction.=20 c) this will provide a layer of isolation to the SLSBs from the actual implementaion of a persistence service.=20 Pinaki Poddar BEA Systems 415.402.7317=20=20 -----Original Message----- From: Hans Prueller [mailto:hans.prueller@gmx.net]=20 Sent: Wednesday, February 21, 2007 1:02 AM To: open-jpa-dev@incubator.apache.org Subject: Howto integrate JPA within EJB2.1 session beans? [architecture] Hi together, I'm sorry for bothering you with numerous basic questions regarding OpenJPA and its usage but I have to migrate existing CMP EJBs to migrate within short time to OpenJPA as we're having stability issues with the current CMP engine.=20 One last question I'd like to ask is regarding the recommended architecture of using OpenJPA within EJB2.1 Stateless sessino beans: I need to work with persistence i.e. the EntityManager throughout all the session beans methods so my idea is to: - create a EntityManagerFactory in the ejbCreate() method of the SLSB - and also create the EntityManager itself in the ejbCreeate() method and store it as a member variable of the SLSB - this would allow easy access within the SB's methods by just using the already initialized entity manager varialbe em.createNamedQuery() .. etc. etc. - clean up should be performed in the ejbRemove() method of the SLSB I think doing so will allow migratino to openJPA with less work than doing the whole lookup procedure in every method separately.=20 what do you think? are there any pitfalls i've 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 _______________________________________________________________________ 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.