openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rick Curtis (JIRA)" <>
Subject [jira] [Commented] (OPENJPA-2142) Merge of a new object does not handle Entity Id field
Date Wed, 25 Apr 2012 15:12:17 GMT


Rick Curtis commented on OPENJPA-2142:

Can you also port the testcases from trunk to 2.2.x ?

> Merge of a new object does not handle Entity Id field
> -----------------------------------------------------
>                 Key: OPENJPA-2142
>                 URL:
>             Project: OpenJPA
>          Issue Type: Bug
>    Affects Versions: 2.3.0, 2.2.1
>            Reporter: Dianne Richards
>            Assignee: Dianne Richards
>             Fix For: 2.3.0, 2.2.1
> When a merge is done on a new object with an Id that contains an Entity, the following
exception occurs:
> <openjpa-2.2.1-SNAPSHOT-r422266:1292578 nonfatal user error> org.apache.openjpa.persistence.InvalidStateException:
Attempt to change a primary key field of an instance that already has a final object id. 
Only new, unflushed instances whose id you have not retrieved can have their primary keys
> FailedObject: hat.entities.Child@38d138d1
> 	at org.apache.openjpa.kernel.StateManagerImpl.assertNoPrimaryKeyChange(
> 	at org.apache.openjpa.kernel.StateManagerImpl.settingObjectField(
> 	at org.apache.openjpa.kernel.AttachStrategy.attachField(
> 	at org.apache.openjpa.kernel.VersionAttachStrategy.attach(
> 	at org.apache.openjpa.kernel.AttachManager.attach(
> 	at org.apache.openjpa.kernel.AttachStrategy.attachCollection(
> 	at org.apache.openjpa.kernel.AttachStrategy.replaceList(
> 	at org.apache.openjpa.kernel.AttachStrategy.attachField(
> 	at org.apache.openjpa.kernel.AttachManager.handleCascade(
> 	at org.apache.openjpa.kernel.AttachManager.attach(
> 	at org.apache.openjpa.kernel.AttachManager.attach(
> 	at org.apache.openjpa.kernel.BrokerImpl.attach(
> 	at org.apache.openjpa.kernel.DelegatingBroker.attach(
> 	at org.apache.openjpa.persistence.EntityManagerImpl.merge(
> 	...
> During the merge, a copy is made of the original object, with a copy of the key fields.
But, if a key field is an Entity, it is not copied, causing this exception in later processing.
The fix is to attach this field immediately after the original object is copied.

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:!default.jspa
For more information on JIRA, see:


View raw message