Affects Version/s: 2.1.1
Fix Version/s: None
Environment:Windows 7, Apache Tomcat 5.5, Eclipse Indigo, OpenJPA plugin handles enhancement, JPA facet, JAX-RS facet
Simple entity without any relations, INT primary key, mapped to Long in POJO.
Entity annotated propery with @Id @GeneratedValue
DMBS: MySQL with JDBC connection.
I started tracking down the issue. I can't get accustomed with the code around it, but I write my experience: (line numbers are based on source release 2.1.1)
- Line 2966: It seems that the method call results in my entity's id field being assigned with a generated value.
- Line 2967: Then in the for loop after that, we reach the same field (the primary key) again at some point, and at
- Line 2968: assignField(i, true) eventually runs on the same code which assigned the Id the first time, which freaks out, as the field value is already set at this point.
org.apache.openjpa.util.ApplicationIds:481 (seems to be a utility method for me)
I cannot investigate further, however I am pretty confident that this is a bug somewhere in the logic, maybe inside StateManagerImpl#assignField method. I believe org.apache.openjpa.util.ApplicationIds:481 should not be invoked the second time, as it's not idempotent.
The exception message:
Primary key field org.inception.teacher4u.persistence.entity.User.userid of org.inception.teacher4u.persistence.entity.User@635e98be has non-default value. The instance life cycle is in PNewState state and hence an existing non-default value for the identity field is not permitted. You either need to remove the @GeneratedValue annotation or modify the code to remove the initializer processing.
|Field||Original Value||New Value|
|Component/s||jpa [ 12311304 ]|
|Status||Open [ 1 ]||Closed [ 6 ]|
|Resolution||Duplicate [ 3 ]|
|Transition||Time In Source Status||Execution Times||Last Executer||Last Execution Date|
|3d 18h 40m||1||Rick Curtis||15/Nov/11 22:19|