Return-Path: Delivered-To: apmail-geronimo-dev-archive@www.apache.org Received: (qmail 63840 invoked from network); 24 Aug 2006 20:50:56 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 24 Aug 2006 20:50:56 -0000 Received: (qmail 87339 invoked by uid 500); 24 Aug 2006 20:50:53 -0000 Delivered-To: apmail-geronimo-dev-archive@geronimo.apache.org Received: (qmail 87294 invoked by uid 500); 24 Aug 2006 20:50:53 -0000 Mailing-List: contact dev-help@geronimo.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: dev@geronimo.apache.org List-Id: Delivered-To: mailing list dev@geronimo.apache.org Received: (qmail 87281 invoked by uid 99); 24 Aug 2006 20:50:53 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 24 Aug 2006 13:50:53 -0700 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [64.124.179.102] (HELO polatsk.objectstyle.org) (64.124.179.102) by apache.org (qpsmtpd/0.29) with SMTP; Thu, 24 Aug 2006 13:50:52 -0700 Received: (qmail 13683 invoked from network); 24 Aug 2006 20:50:31 -0000 Received: from unknown (HELO ?JB?cr??IPv6:::1?) (127.0.0.1) by localhost with SMTP; 24 Aug 2006 20:50:31 -0000 Mime-Version: 1.0 (Apple Message framework v752.2) In-Reply-To: <93ACF16B-B5BF-4D29-9C70-48C9C7E6C2B5@yahoo.com> References: <93ACF16B-B5BF-4D29-9C70-48C9C7E6C2B5@yahoo.com> Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Message-Id: <851F29E7-DC8A-452F-8634-6CF5B15BCC61@objectstyle.org> Content-Transfer-Encoding: 7bit From: Andrus Adamchik Subject: Re: Some jpa questions Date: Fri, 25 Aug 2006 00:50:33 +0400 To: dev@geronimo.apache.org X-Mailer: Apple Mail (2.752.2) X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Hi David, On Aug 24, 2006, at 9:41 PM, David Jencks wrote: > I've been looking at the ejb 3 persistence spec and it looks to me > as if there are some poorly explained bits. That is certainly the case. > Anyone have any clues about these or any clue about where I could > get an answer? > > 1. The @PersistenceContext annotation appears to be per jee > component (web app or ejb). You can specify a map of properties to > pass in to the EMF.createPersistenceContext method. Lets suppose > you have tx scoped PC, and you have 2 ejbs with tx Required and one > calls the other, and one specifies a map of properties and the > other doesn't (or they specify different maps). What's supposed to > happen? I guess propagation of context within a transaction takes precedence over property overrides: Section 5.8.2: "If a persistence context is already associated with a JTA transaction, the container uses that persistence context for subsequent invocations within the scope of that transaction, according to the semantics for persistence context propagation defined in section 5.6.3." > 2. What's supposed to happen when you try to use a CM tx scoped EM > outside a JTA tx? Section 5.6.1 seems to imply we aren't supposed > to just throw an exception, but section 5.9.1 seems to imply there > is no provider EM in back of the CM EM to do any work without a JTA > tx. Are we supposed to create and close a provider EM for each > call outside a tx? Good question... I have no idea. > - How heavyweight are EntityManagers? I guess this could be implementation specific, but they are lightweight in Cayenne, and I assume they are lightweight in other providers as well. > Is it more efficient to create a new one or pool them? While the spec provides some leeway (see below), container with pluggable provider has no way of knowing the best strategy. My vote is to avoid pooling EntityManagers by default. Section 5.8.2: "It is undefined whether a new entity manager instance is created for every persistence context, or whether entity manager instances are sometimes reused. Exactly how the container maintains the association between persistence context and JTA transaction is not defined." > Are they cheap enough so every CM tx-scoped EM can have a "outside > tx" provider EM attached to it in case anyone is dumb enough to do > work outside a tx? Is this more or less resource efficient than > creating a new EM for each out-of-tx use? Not sure I understand the question. Andrus