Hi Daryl, I think your diagnosis is correct -- a detached instance is being identified wrongly as new -- that is the root cause. I am asking these questions to figure out at what point OpenJPA went off track in determining the detached instance as persistent-new. Does these Foo/Bar instances have a Version field? And if yes, is the value of the version field for the detached instance non-default (i.e. say non-zero for a primitive type version field of non-null for a object type field)? If you want to probe it further by yourself, do the following: 1. decompile th enhanced classes. 2. see the generated code for pcGetDetachedState() method. This is the method that is used to determine whether an input argument (or reachable) instance during merge() is detached or not.
Daryl Stultz wrote: > > On Mon, Jan 4, 2010 at 12:28 PM, Pinaki Poddar <[email protected]> wrote: > >> >> Hi Daryl, >> What is the strategy used to generate primary key values for model.Foo >> and >> model.Bar? >> >> > All the PK's are assigned using: > > @GeneratedValue(strategy = GenerationType.IDENTITY) > except in one unrelated case where the sequence name is too long > (truncated). (I'm using PostgreSQL.) > > > And how the primary key values were assigned to the offending instances? > > > > I'm not quite sure how to answer your question. The instance was created > and > persisted, not by the user in the web application, but by a SOAP interface > / > scheduled process. So the PK was assigned by the database in an earlier > transaction. I believe the error condition reported is misleading. It's > not > that we have a new instance with an ID pre-assigned, but rather we have a > preexisting (detached or managed) entity that now appears to be new. > > > I'm on OpenJPA 1.2.1. > > > -- > Daryl Stultz > _____________________________________ > 6 Degrees Software and Consulting, Inc. > http://www.6degrees.com > mailto:[email protected] > > ----- Pinaki -- View this message in context: http://n2.nabble.com/PC-object-losing-state-tp4249977p4251195.html Sent from the OpenJPA Users mailing list archive at Nabble.com.
