Return-Path: Delivered-To: apmail-incubator-open-jpa-dev-archive@locus.apache.org Received: (qmail 82875 invoked from network); 30 Apr 2007 18:58:46 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 30 Apr 2007 18:58:46 -0000 Received: (qmail 29185 invoked by uid 500); 30 Apr 2007 18:58:53 -0000 Delivered-To: apmail-incubator-open-jpa-dev-archive@incubator.apache.org Received: (qmail 29160 invoked by uid 500); 30 Apr 2007 18:58:52 -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 29151 invoked by uid 99); 30 Apr 2007 18:58:52 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 30 Apr 2007 11:58:52 -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 jason.m.hanna.at.coincident@gmail.com designates 209.85.132.243 as permitted sender) Received: from [209.85.132.243] (HELO an-out-0708.google.com) (209.85.132.243) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 30 Apr 2007 11:58:44 -0700 Received: by an-out-0708.google.com with SMTP id b2so1482509ana for ; Mon, 30 Apr 2007 11:58:24 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=AzU0sBHIP1DWn1M0ryc13i/f3YEHLlLjw7BO1yKMOtgxEgh6C3W93y5Q1a4w1jpaKtJIpn5a3SFD5UFOTDMG4UvqA6ydVgbmNTw5B4uBRHQcxuB3bzkOvH3tYjCZkHRPyqBkv9uzWnpi8u72tD7mNOpKg6R/pLlyvLHh3r9Kn1I= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=rrJmZ/QS3KAX1cLBhOieNrBkOgVzK5+Cs/+Oy9kaNaM9s/wFA+6YeX6zxvPUUtAiggHAzHA7cqruZAxmHMLvTeBB07adgdhpvZbd8pm2DvPbJe3GyhhShMgjUzBNcvtC7bKLZcAsV4I+EkaXFSgT7P+/45dfvxMV4rZAGZ+b0Ok= Received: by 10.100.43.9 with SMTP id q9mr4390705anq.1177959503484; Mon, 30 Apr 2007 11:58:23 -0700 (PDT) Received: by 10.100.241.15 with HTTP; Mon, 30 Apr 2007 11:58:23 -0700 (PDT) Message-ID: <8f9e78f00704301158x66cd55edla0f400a4a64e3506@mail.gmail.com> Date: Mon, 30 Apr 2007 14:58:23 -0400 From: "Jason Hanna" To: open-jpa-dev@incubator.apache.org Subject: Re: Merge Detached Entity Problem In-Reply-To: <10247785.post@talk.nabble.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <8f9e78f00704271013k3c4fb839lbfd6d13419b1b761@mail.gmail.com> <10247785.post@talk.nabble.com> X-Virus-Checked: Checked by ClamAV on apache.org Hi Roger, I don't know anything about your project or environment, but I've been doing some testing with PostgreSQL today and I'm finding it seems to work much better with OpenJPA than MySQL. I've recently come out of the corporate world, and Oracle was our "standard" database platform. I've just started working with open source db platforms, and I'm finding MySQL has some limitations that might prove problematic when using OpenJPA and programming robust database-backed web applications. I know it's a supported platform, but I'd be willing to bet there are a lot more caveats (and remaining bugs) when using MySQL as opposed to Oracle or PostgreSQL. I'm sure some of the experts on this list can speak to this point, but MySQL apparently does not support deferred foreign key constraints. In my particular use case, I was trying to merge a detached object that contained a reference to another detached object. The cascade update seemed to succeed only if both detached objects contained changes. Adding the @Version annotation and columns to my tables fixed the problem, but then I ran into an intermittent 'Optimistic Lock' exception when attempting to remove the same type of detached object. It appeared to be a race condition, as sometimes the delete would succeed, and other times it would fail. I'm speculating that this occured because I had cascade delete enabled on my foreign key constraint and CascadeType.ALL enabled for my referenced object. Since I was using MySQL, the cascade delete on the foreign key constraint couldn't be deferred until transaction commit. It would sometimes execute prior to OpenJPA execution of the 2nd delete statement. I believe that's where the (legitimate) intermittent optimistic lock exception was coming from for this removal use case. I've just finished setting up my database, schema, and tables on PostgreSQL 8.2.4. I'm finding that with deferred foreign key constraints enabled, my cascading issues seem to have disappeared. As an added bonus I was able to revert to the initial code I created for my DAOs because JPA was working without any additional (and seemingly unnecessary) manipulation of my referenced objects. If alternate database platforms are an option, I'd recommend looking at PostgreSQL. Support for deferred constraints, plus better handling of BLOBs and full support for multi-version concurrency control (MVCC). Cheers, -jmh On 4/29/07, roger.keays wrote: > > > Jason Hanna wrote: > > > > org.apache.openjpa.persistence.RollbackException: Optimistic locking > > errors were detected when flushing to the data store. The following > > objects may have been concurrently modified in another transaction: > > [com.coincident.green.beans.User-com.coincident.green.beans.User-1] > > > > I've just fixed a similar issue in my app [1]. Maybe it is the same problem > with foreign key constraints [2] > > [1] http://www.nabble.com/forum/ViewPost.jtp?post=10247539&framed=y > [2] http://www.nabble.com/forum/ViewPost.jtp?post=7395124&framed=y > -- > View this message in context: http://www.nabble.com/Merge-Detached-Entity-Problem-tf3658825.html#a10247785 > Sent from the open-jpa-dev mailing list archive at Nabble.com. > >