openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Pinaki Poddar (JIRA)" <>
Subject [jira] Commented: (OPENJPA-673) Entity using Generated Value for primary key and a Version field and no DetachedStae fails to merge
Date Mon, 04 Aug 2008 22:44:44 GMT


Pinaki Poddar commented on OPENJPA-673:

Following simple Test
	public void testSimpleMerge() {
		EntityManager em1 = emf.createEntityManager();
		PObject pc = new PObject();
		pc.setData("Persist NEW");
		EntityManager em2 = emf.createEntityManager();
with a Simple entity
public class PObject {
	private long id;
	private String data;
	private int version;

fails with 
<openjpa-1.3.0-SNAPSHOT-r422266:681977M nonfatal user error> org.apache.openjpa.persistence.InvalidStateException:
The generated value processing detected an existing value assigned to this field:
 This existing value was either provided via an initializer or by calling the setter method.
 You either need to remove the @GeneratedValue annotation or modify the code to remove the
initializer processing.
	at org.apache.openjpa.util.ApplicationIds.assign(
	at org.apache.openjpa.util.ApplicationIds.assign(
	at org.apache.openjpa.jdbc.kernel.JDBCStoreManager.assignObjectId(
	at org.apache.openjpa.kernel.DelegatingStoreManager.assignObjectId(
	at org.apache.openjpa.kernel.StateManagerImpl.assignObjectId(
	at org.apache.openjpa.kernel.StateManagerImpl.preFlush(
	at org.apache.openjpa.kernel.PNewState.beforeFlush(
	at org.apache.openjpa.kernel.StateManagerImpl.beforeFlush(
	at org.apache.openjpa.kernel.BrokerImpl.flush(
	at org.apache.openjpa.kernel.BrokerImpl.flushSafe(
	at org.apache.openjpa.kernel.BrokerImpl.beforeCompletion(
	at org.apache.openjpa.kernel.LocalManagedRuntime.commit(
	at org.apache.openjpa.kernel.BrokerImpl.commit(
	at org.apache.openjpa.kernel.DelegatingBroker.commit(
	at org.apache.openjpa.persistence.EntityManagerImpl.commit(
	at jiraXXX.TestMerge.testSimpleMerge(

"Making simple things easy, and difficult things possible" -- a sign of good design

> Entity using Generated Value for primary key and a Version field and no DetachedStae
fails to merge 
> ----------------------------------------------------------------------------------------------------
>                 Key: OPENJPA-673
>                 URL:
>             Project: OpenJPA
>          Issue Type: Bug
>            Reporter: Pinaki Poddar
>             Fix For: 1.2.0
> Entities using GeneratedValue for primary key, a version field an dno detached state
fails to merge.
> The issue lies with identifying :"what makes a new instance?"
> It is not obvious why VersionAttachStrategy does not use version field to detect newness.
Instead it depends on detached state which is obviously null for instances not using a Detached
> Can someone shade some light on why VersionAttachStrategy ignores version field to detect

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

View raw message