Return-Path: Delivered-To: apmail-openjpa-users-archive@locus.apache.org Received: (qmail 5675 invoked from network); 13 May 2008 09:41:29 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 13 May 2008 09:41:29 -0000 Received: (qmail 84739 invoked by uid 500); 13 May 2008 09:41:31 -0000 Delivered-To: apmail-openjpa-users-archive@openjpa.apache.org Received: (qmail 84689 invoked by uid 500); 13 May 2008 09:41:31 -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 84678 invoked by uid 99); 13 May 2008 09:41:31 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 13 May 2008 02:41:31 -0700 X-ASF-Spam-Status: No, hits=2.6 required=10.0 tests=DNS_FROM_OPENWHOIS,SPF_HELO_PASS,SPF_PASS,WHOIS_MYPRIVREG X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of lists@nabble.com designates 216.139.236.158 as permitted sender) Received: from [216.139.236.158] (HELO kuber.nabble.com) (216.139.236.158) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 13 May 2008 09:40:42 +0000 Received: from isper.nabble.com ([192.168.236.156]) by kuber.nabble.com with esmtp (Exim 4.63) (envelope-from ) id 1Jvr0C-0006Nz-ND for users@openjpa.apache.org; Tue, 13 May 2008 02:40:56 -0700 Message-ID: <17204751.post@talk.nabble.com> Date: Tue, 13 May 2008 02:40:56 -0700 (PDT) From: John Leach To: users@openjpa.apache.org Subject: Re: InvalidStateException: Attempt to set column "client.version" to two different values In-Reply-To: <17178751.post@talk.nabble.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Nabble-From: john.leach@syger.com References: <17163045.post@talk.nabble.com> <3C272841-7FBC-4E01-86FF-81F5415BE733@SUN.com> <17165114.post@talk.nabble.com> <17178751.post@talk.nabble.com> X-Virus-Checked: Checked by ClamAV on apache.org Dear list, The first showstopper InvalidStateException: Attempt to set column "client.version" to two different values... where the version field is being updated (this is an optimistic locking field, and has a @Version annotation), is being caused by a @PreUpdate annotation in the abstract model class. If I remove the annotation, all works fine, put it back and the exception returns. I am inclined to think that this is a bug - in the above example a client (many to one) is removed from a user (one to many), then I call flush. Firstly I don't understand why the client is updated, but this may have to do with the fact that I haven't been able to set a 'delete orphan' cascade yet. Still, no values in the client were changed (by my code, at least). The update calls the @PreUpdate method, but then seems to increment the version number *again*. The second showstopper is finding a way to change the metadata before an EntityManager is created. The intention is to provide a 'third' alternative to annotations and/or persistence.xml, where the entity classes contain only JPA annotations, with any remaining changes being made programmatically. The one-to-many example defines CascadeType.ALL, but actually requires a 'delete-orphans' extension for the tests to succeed. Again, my many attempts at hooking into the properties openjpa.BrokerFactory or openjpa.BrokerImpl or openjpa.MetaDataFactory all met with failure of one sort or the other (mostly ClassCast exceptions within the OpenJPA code). Any help would be greatly appreciated. The code is available in an open source project, called Spikes and can be downloaded via Subversion with the command: svn checkout https://lab.jugtorino.it/svn/sandbox/spikes/trunk spikes Best regards John John Leach wrote: > > Hello list, > Spikes is now Java 5 compatible. I also fixed a nasty mishtak in the > manager. Say after me persist/merge != save/update. Added ant task > openjpac bytecode twiddling before running the tests, and guess what? Same > problem, er, persists. Sigh. > > John > > > John Leach wrote: >> >> Hello Craig, >> Oops, I compiled parancoe-yaml with Eclipse, and didn't check the >> version. Should compile with Java 5 though. My mistake. Spike compiles >> with the ant task set to 1.5 source and target. I'll recompile the jar >> file and update the svn repository this weekend. >> >> John >> >> >> Craig L Russell wrote: >>> >>> Hi John, >>> >>> Does the project require Java 6? I checked out the sources and cd >>> trunk; ant. It appears that one of the dependencies is compiled with >>> Java 6. >>> test-compile: >>> [javac] Compiling 29 source files to /Users/clr/spikes/trunk/bin >>> [javac] /Users/clr/spikes/trunk/java/src/org/syger/fixtures/ >>> YamlHelper.java:28: cannot access org.parancoe.yaml.Yaml >>> [javac] bad class file: /Users/clr/spikes/trunk/extlib/parancoe- >>> yaml.jar(org/parancoe/yaml/Yaml.class) >>> [javac] class file has wrong version 50.0, should be 49.0 >>> [javac] Please remove or make sure it appears in the correct >>> subdirectory of the classpath. >>> [javac] import org.parancoe.yaml.Yaml; >>> [javac] ^ >>> [javac] 1 error >>> >>> more below... >>> >>> On May 10, 2008, at 7:38 AM, John Leach wrote: >>> >>>> >>>> Dear list, >>>> As part of a (very) small open source project to provide domain entity >>>> mapping and association examples, together with a programmatic >>>> interface to >>>> reach outside the JPA 1.0 specifications, I am struggling with two >>>> problems >>>> using OpenJPA. >>>> >>>> I had better warn you all that I am a freelance consultant working >>>> in Italy >>>> and I use and will be using this work to sell both the advantages and >>>> disadvantages (but with solutions) of using JPA 1.0. to my clients. >>>> >>>> The first showstopper is an InvalidStateException: Attempt to set >>>> column >>>> "client.version" to two different values... where the version field >>>> is being >>>> updated (this is an optimistic locking field, and has a @Version >>>> annotation), the SQL query being performed seems to be: >>>> UPDATE client SET lastUpdated = ?, version = ? WHERE id = ? AND >>>> version = ? >>>> [params=(Timestamp) 2008-05-10 15:58:16.593, (int) 3, (long) 3, >>>> (int) 2] >>> >>> This SQL seems correct. It's updating the lastUpdated and version >>> columns and verifying that the version is correct. Where does this >>> error occur? >>> >>> Craig >>>> >>>> The same annotated entities work just fine with Hibernate and >>>> EclipseLink - >>>> for what that's worth. >>>> I have even tried adding openjpac in the ant task, but the results >>>> remain >>>> the same. >>>> I am convinced that this is a Spring/OpenJPA configuration problem, >>>> but >>>> being a relative novice with Spring (and OpenJPA) I have been >>>> beating my >>>> head against the proverbial brick wall for two days, and not even a >>>> dent in >>>> the wall to show for my efforts. >>>> >>>> The second showstopper is finding a way to change the metadata >>>> before an >>>> EntityManager is created. The intention is to provide a 'third' >>>> alternative >>>> to annotations and/or persistence.xml, where the entity classes >>>> contain only >>>> JPA annotations, with any remaining changes being made >>>> programmatically. The >>>> one-to-many example defines CascadeType.ALL, but actually requires a >>>> 'delete-orphans' extension for the tests to succeed. Again, my many >>>> attempts >>>> at hooking into the properties openjpa.BrokerFactory or >>>> openjpa.BrokerImpl >>>> or openjpa.MetaDataFactory all met with failure of one sort or the >>>> other >>>> (mostly ClassCast exceptions within the OpenJPA code). >>>> >>>> Any help would be greatly appreciated. I am working 'in >>>> collaboration with' >>>> two Java User Groups (Torino and Trento), but it's really me who >>>> wrote most >>>> of the code. >>>> >>>> The open source project, called Spikes (guess why) can be downloaded >>>> via >>>> Subversion with the command: >>>> svn checkout https://lab.jugtorino.it/svn/sandbox/spikes/trunk spikes >>>> There is a Trac site at >>>> http://lab.jugtorino.it/trac/sandbox/wiki/Spikes >>>> , >>>> which I have converted to English in most places, and also an >>>> article (which >>>> started the project rolling) >>>> http://www.syger.it/Tutorials/JPA10Gotchas.html >>>> >>>> Best regards >>>> John Leach, Verona, Italy >>>> -- >>>> View this message in context: >>>> http://www.nabble.com/InvalidStateException%3A-Attempt-to-set-column-%22client.version%22-to-two-different-values-tp17163045p17163045.html >>>> Sent from the OpenJPA Users mailing list archive at Nabble.com. >>>> >>> >>> 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! >>> >>> >>> >>> >> >> > > -- View this message in context: http://www.nabble.com/InvalidStateException%3A-Attempt-to-set-column-%22client.version%22-to-two-different-values-tp17163045p17204751.html Sent from the OpenJPA Users mailing list archive at Nabble.com.