Return-Path: Delivered-To: apmail-openjpa-users-archive@locus.apache.org Received: (qmail 41837 invoked from network); 22 Dec 2008 16:42:25 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 22 Dec 2008 16:42:25 -0000 Received: (qmail 56573 invoked by uid 500); 22 Dec 2008 16:42:24 -0000 Delivered-To: apmail-openjpa-users-archive@openjpa.apache.org Received: (qmail 56542 invoked by uid 500); 22 Dec 2008 16:42:24 -0000 Mailing-List: contact users-help@openjpa.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@openjpa.apache.org Delivered-To: mailing list users@openjpa.apache.org Received: (qmail 56531 invoked by uid 99); 22 Dec 2008 16:42:24 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 22 Dec 2008 08:42:24 -0800 X-ASF-Spam-Status: No, hits=-1.8 required=10.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_MED,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: local policy includes SPF record at spf.trusted-forwarder.org) Received: from [64.18.2.218] (HELO exprod7og116.obsmtp.com) (64.18.2.218) by apache.org (qpsmtpd/0.29) with SMTP; Mon, 22 Dec 2008 16:42:16 +0000 Received: from source ([209.85.218.21]) by exprod7ob116.postini.com ([64.18.6.12]) with SMTP ID DSNKSU/DUn0IvSkLrFCXcnbctbH/iejuJTlm@postini.com; Mon, 22 Dec 2008 08:41:56 PST Received: by bwz14 with SMTP id 14so5862951bwz.23 for ; Mon, 22 Dec 2008 08:41:54 -0800 (PST) Received: by 10.223.108.208 with SMTP id g16mr5105584fap.37.1229964113788; Mon, 22 Dec 2008 08:41:53 -0800 (PST) Received: by 10.223.126.211 with HTTP; Mon, 22 Dec 2008 08:41:53 -0800 (PST) Message-ID: Date: Mon, 22 Dec 2008 11:41:53 -0500 From: "Daryl Stultz" To: "OpenJPA User List" Subject: EntityManager handling MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_1912_2676970.1229964113782" X-Virus-Checked: Checked by ClamAV on apache.org ------=_Part_1912_2676970.1229964113782 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Hi all, I'm new to JPA/OpenJPA. I have managed to get OpenJPA to use my connection pool for connections. My next step is to make something handy for getting EntityManager instances. I am writing web applications (Tomcat). What I do with connections is initialize my connection pool at web app startup and close the pool at web app shut it down. Each request to the web application gets its own connection which is guaranteed to be closed/freed at the end of the request. I'm looking for details about how this pattern might match JPA. Is EntityManagerFactory analogous to the connection pool in that I should create it upon web app startup and close it at web app shut down? Is EntityManager analogous to connection in that each request should acquire its own EM and then close it at the end of the request? I have read in the docs about the handling of concurrency. It seems the EM can detect when 2 objects representing the same row in the database are attempting a concurrent update (load A and B instances of same row, change A and B, update A, cool, update B, error). Is this handled within a single EM instance? If so, it seems an EM needs to be a single instance across all users, but it appears only one transaction at a time is allowed, so that can't be right. Any help clearing this up is appreciated. -- Daryl Stultz _____________________________________ 6 Degrees Software and Consulting, Inc. http://www.6degrees.com mailto:daryl@6degrees.com ------=_Part_1912_2676970.1229964113782--