Return-Path: Delivered-To: apmail-incubator-open-jpa-dev-archive@locus.apache.org Received: (qmail 41300 invoked from network); 10 Apr 2007 21:57:27 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 10 Apr 2007 21:57:27 -0000 Received: (qmail 11053 invoked by uid 500); 10 Apr 2007 21:57:33 -0000 Delivered-To: apmail-incubator-open-jpa-dev-archive@incubator.apache.org Received: (qmail 11032 invoked by uid 500); 10 Apr 2007 21:57:33 -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 11023 invoked by uid 99); 10 Apr 2007 21:57:33 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 10 Apr 2007 14:57:33 -0700 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.39 as permitted sender) Received: from [66.248.192.39] (HELO repmmg02.bea.com) (66.248.192.39) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 10 Apr 2007 14:57:26 -0700 Received: from repmmr01.bea.com (repmmr01.bea.com [10.160.29.71]) by repmmg02.bea.com (Switch-3.2.5/Switch-3.2.5) with ESMTP id l3ALv428001009 for ; Tue, 10 Apr 2007 14:57:04 -0700 Received: from repbex02.amer.bea.com (repbex02.bea.com [10.160.26.99]) by repmmr01.bea.com (Switch-3.2.5/Switch-3.2.5) with ESMTP id l3ALv3nS029090 for ; Tue, 10 Apr 2007 14:57:03 -0700 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: 7bit Subject: RE: Can I reuse instances? Date: Tue, 10 Apr 2007 14:57:06 -0700 Message-ID: <7D856CDFE035FF45A0420ACBD71BDD6303E40022@repbex02.amer.bea.com> In-Reply-To: <963203EF-D420-4A2B-A218-498384B5D85D@SUN.com> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: Can I reuse instances? Thread-Index: Acd7CX4LP1E3zzGKRvqLttH7b2CBGwApaREg References: <77F77403-9FB9-4525-980C-01BE6C155836@iq80.com> <7D856CDFE035FF45A0420ACBD71BDD6303D1F68D@repbex02.amer.bea.com> <9DF0F4A4-3EBC-47BF-9609-C934904D29CF@iq80.com> <963203EF-D420-4A2B-A218-498384B5D85D@SUN.com> From: "Patrick Linskey" To: x-BEA-PMX-Instructions: AV x-BEA-MM: Internal-To-External X-Virus-Checked: Checked by ClamAV on apache.org > Your implementation uses JPA Entities to hold the state. These JPA > Entities are not at all specified by CMP Entity Beans. JPA Entities > as cheap to create so all you need to do is hold on to the ids and > when you need state from the database, ask JPA EntityManager for the > state. If the state is already in the second level cache, this is > very cheap to access. I imagine that it's also possible that Dain's CMP entity beans are themselves the JPA entities, rather than beans that delegate on to a JPA entity. -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: Craig.Russell@Sun.COM [mailto:Craig.Russell@Sun.COM] > Sent: Monday, April 09, 2007 5:45 PM > To: open-jpa-dev@incubator.apache.org > Subject: Re: Can I reuse instances? > > Hi Dain, > > On Apr 9, 2007, at 11:10 AM, Dain Sundstrom wrote: > > > On Apr 8, 2007, at 1:56 PM, Craig L Russell wrote: > > > >> Hi Dain, > >> > >> I haven't looked in detail at the life cycle of CMP beans in a > >> couple of years, but in general you can't simply keep the > state of > >> the underlying Entities through the life cycle. CMP beans are > >> pooled and reused in transaction contexts and you have to > load the > >> state at specific points in the life cycle. > > > > It depends on the commit option the container is using. In commit > > option A, you assume the cmp engine is the sole user of the > > database, so you don't need to load. Normally people use commit > > option B where you keep instances activated with a specific > primary > > key and reload the data in each tx. > > > >> Using the primary key stored in the CMP bean to do em.find at the > >> appropriate time is the obvious way to take advantage of the em > >> second level cache. To the extent that this is not efficient, we > >> should fix it in the JPA layer not the CMP layer. > > > > I would prefer to keep as much of the CMP stuff on the CMP side as > > possible so the JPA implementation can focus on JPA issues. One > > of the assumption of JPA is that entities are light weight and > > cheap to create, so you take the safe route and construct a > new one > > when every you need an instance. In CMP the assumption is that > > entity instances are expensive to create, so less safe route and > > you pool them. Reusing instances is really a CMP problem, but I > > don't think it can be implemented without the help of the > JPA engine. > > I'm afraid we're getting wrapped around the axle on definitions. > Here's what I'm trying to get across: > > CMP Entity Beans are expensive to create and there's a lot of > required behavior to manage them. You pretty much have to implement > the life cycle in the spec. It's your choice how to implement the > "state" part of the beans. You can use wrappers around various kinds > of state objects like ResultSet or generated classes that contain > fields with the state. > > Your implementation uses JPA Entities to hold the state. These JPA > Entities are not at all specified by CMP Entity Beans. JPA Entities > as cheap to create so all you need to do is hold on to the ids and > when you need state from the database, ask JPA EntityManager for the > state. If the state is already in the second level cache, this is > very cheap to access. > > Craig > > > > -dain > > > > > > Craig Russell > Architect, Sun Java Enterprise System http://java.sun.com/products/jdo > 408 276-5638 mailto:Craig.Russell@sun.com > P.S. A good JDO? O, Gasp! > > 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.