> Is the entity deleted after the unique-constraint violation excption?

> And do I have to create new Instances of the object and all it's
associated ones?
Yes, and no. If you are quite studious, you can get a rolled back Entity
back into a 'clean' state so that you can successfully merge them back into
a persistence context (you'll need to clear out _pcVersionInit, version
fields, auto generated Id fields, and the StateManager field)... but the
easiest path might be to copy all of the data over to fresh(newly created)
Entities.


On Mon, Oct 14, 2013 at 7:24 AM, susanne_j <susann...@gmx.de> wrote:

> Hello openjpa list,
>
> I currently have the following problem and I'm now a bit helpless, how I
> could avoid it ...
>
> I'm using an optimistic locking id in my table and I have a
> unique-constraint on this table.
>
> If the user now maintains the fields, that all ends up in an attempt to
> save
> the record which results in a unique-constraint violation exception (with
> an
> automatic rollback), I show the exception to the user and the user has the
> possibility to change the fields for the unique-constraint. I open a new
> transaction and try to merge the - now detached - object with the former
> uc-violation back into the new transaction-context. But now the merge call
> runs into an optimistic locking exception
> "Attempted to attach deleted instance type "class xxx.StGsPartner" with oid
> "9".  If the instance is new, the version field should be left to its
> default value."
>
> Is the entity deleted after the unique-constraint violation excption? And
> do
> I have to create new Instances of the object and all it's associated ones?
> Or is there another way to get the object (and the associated) back into
> the
> transaction-context?
>
> Thanks in advance if you could help me with it!
>
> Best regards,
> Susanne.
>
>
>
> --
> View this message in context:
> http://openjpa.208410.n2.nabble.com/Problem-with-the-optimistic-locking-id-after-a-unique-constraint-violation-exception-tp7585160.html
> Sent from the OpenJPA Users mailing list archive at Nabble.com.
>



-- 
*Rick Curtis*

Reply via email to