openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rick Curtis (JIRA)" <j...@apache.org>
Subject [jira] Created: (OPENJPA-1324) Unexpected error when an Entity has multiple columns named id ("id" and "ID")
Date Wed, 23 Sep 2009 14:01:16 GMT
Unexpected error when an Entity has multiple columns named id ("id" and "ID")
-----------------------------------------------------------------------------

                 Key: OPENJPA-1324
                 URL: https://issues.apache.org/jira/browse/OPENJPA-1324
             Project: OpenJPA
          Issue Type: Bug
          Components: kernel
         Environment: Win XP, MySQL 5.1.30
            Reporter: Rick Curtis


When doing some artistic testing I came across this problem when I had two fields named id
(id and ID) in my Entity. I'm not sure if this is a valid usage, but I'm documenting this
issue to revisit at a later date.

Note: The table that was generated by the Entity definition below had only one column named
'id'.

Scenario:
em1.getTransaction().begin();
em1.persist(new Book());
em1.getTransaction().commit();

@Entity
public class Book {
    @Id
    @GeneratedValue(strategy=GenerationType.IDENTITY)
    private long id;
    private long ID;
....
}

Exception:
...
Caused by: <openjpa-2.0.0-SNAPSHOT-r422266:804085M fatal user error> org.apache.openjpa.persistence.ArgumentException:
Attempt to assign id "main.Book-0" to new instance "main.Book-main.Book-0" failed; there is
already an object in the L1 cache with this id. You must delete this object (in a previous
transaction or the current one) before reusing its id.  This error can also occur when a horizontally
or vertically mapped classes uses auto-increment application identity and does not use a hierarchy
of application identity classes.
FailedObject: main.Book-main.Book-0
	at org.apache.openjpa.kernel.ManagedCache.commitNew(ManagedCache.java:240)
	at org.apache.openjpa.kernel.BrokerImpl.setStateManager(BrokerImpl.java:3990)
	at org.apache.openjpa.kernel.StateManagerImpl.commit(StateManagerImpl.java:1134)
	at org.apache.openjpa.kernel.BrokerImpl.endTransaction(BrokerImpl.java:2346)
	... 6 more

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


Mime
View raw message