From open-jpa-dev-return-1551-apmail-incubator-open-jpa-dev-archive=incubator.apache.org@incubator.apache.org Fri Jan 05 00:09:27 2007 Return-Path: Delivered-To: apmail-incubator-open-jpa-dev-archive@locus.apache.org Received: (qmail 98969 invoked from network); 5 Jan 2007 00:09:27 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 5 Jan 2007 00:09:27 -0000 Received: (qmail 36559 invoked by uid 500); 5 Jan 2007 00:09:33 -0000 Delivered-To: apmail-incubator-open-jpa-dev-archive@incubator.apache.org Received: (qmail 36533 invoked by uid 500); 5 Jan 2007 00:09: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 36524 invoked by uid 99); 5 Jan 2007 00:09:33 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 04 Jan 2007 16:09:33 -0800 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (herse.apache.org: domain of lists@nabble.com designates 72.21.53.35 as permitted sender) Received: from [72.21.53.35] (HELO talk.nabble.com) (72.21.53.35) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 04 Jan 2007 16:09:23 -0800 Received: from [72.21.53.38] (helo=jubjub.nabble.com) by talk.nabble.com with esmtp (Exim 4.50) id 1H2cdq-00071y-NU for open-jpa-dev@incubator.apache.org; Thu, 04 Jan 2007 16:09:02 -0800 Message-ID: <8170503.post@talk.nabble.com> Date: Thu, 4 Jan 2007 16:09:02 -0800 (PST) From: "roger.keays" To: open-jpa-dev@incubator.apache.org Subject: race condition in a transaction? MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Nabble-From: roger.keays@ninthavenue.com.au X-Virus-Checked: Checked by ClamAV on apache.org Hi, I'm just wondering if the following code could be subject to a race condition when accessed by many threads em.getTransaction().begin(); bean.setCount(bean.getCount() + 1); em.getTransaction().commit(); My understanding is that it would be possible here for two threads to set the same value for the new count (given that each thread has a different em). Is that correct? Do I have to use an UPDATE query to make this function as expected? Thanks, Roger -- View this message in context: http://www.nabble.com/race-condition-in-a-transaction--tf2922964.html#a8170503 Sent from the open-jpa-dev mailing list archive at Nabble.com.