openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rick Curtis (JIRA)" <>
Subject [jira] Created: (OPENJPA-1255) InvalidStateException when using @MappedById and @JoinColumn on a unidirectional @ManyToOne relationship
Date Wed, 19 Aug 2009 18:56:14 GMT
InvalidStateException when using @MappedById and @JoinColumn on a unidirectional @ManyToOne

                 Key: OPENJPA-1255
             Project: OpenJPA
          Issue Type: Bug
          Components: jdbc
            Reporter: Rick Curtis

I found that if I have a ManyToOne relationship using the JoinColumn and MappedById annotations
I receive the following exception:

<openjpa-2.0.0-SNAPSHOT-r422266:804085M fatal store error> org.apache.openjpa.util.StoreException:
The transaction has been rolled back.  See the nested exceptions for details on the errors
that occurred.
	at org.apache.openjpa.kernel.BrokerImpl.newFlushException(
	at org.apache.openjpa.kernel.BrokerImpl.flush(
	at org.apache.openjpa.persistence.EntityManagerImpl.commit(
	at main.Driver.main(
Caused by: <openjpa-2.0.0-SNAPSHOT-r422266:804085M fatal user error> org.apache.openjpa.util.InvalidStateException:
Attempt to set column "" to two different values: (class java.lang.Integer)"1", (class
java.lang.Integer)"2" This can occur when you fail to set both sides of a two-sided relation
between objects, or when you map different fields to the same column, but you do not keep
the values of these fields in synch.
	at org.apache.openjpa.jdbc.sql.PrimaryRow.setObject(
	at org.apache.openjpa.jdbc.sql.RowImpl.setInt(
	at org.apache.openjpa.jdbc.meta.strats.PrimitiveFieldStrategy.update(
	at org.apache.openjpa.jdbc.meta.strats.PrimitiveFieldStrategy.insert(
	at org.apache.openjpa.jdbc.meta.FieldMapping.insert(
	at org.apache.openjpa.jdbc.kernel.AbstractUpdateManager.insert(
	at org.apache.openjpa.jdbc.kernel.AbstractUpdateManager.populateRowManager(
	at org.apache.openjpa.jdbc.kernel.AbstractUpdateManager.flush(
	at org.apache.openjpa.jdbc.kernel.AbstractUpdateManager.flush(
	at org.apache.openjpa.jdbc.kernel.JDBCStoreManager.flush(
	at org.apache.openjpa.kernel.DelegatingStoreManager.flush(
	... 8 more

I created this problem by running the following code in a JSE environment:
      E2 e2 = new E2(1);
      em.persist(new E1(e2,2));
      em.persist(new E1(e2,3));

The domain model is as follows:

public class E1 {
    private int id;

    @ManyToOne(cascade = CascadeType.PERSIST)
    @JoinColumn(name = "something_fk")
    private E2 e2;

    public E1(E2 e, int i) {
        e2 = e;
        id = i;

    public E1() {
}//end E1
public class E2 {
    private int id;

    public E2(int i) {
        id = i;

    public E2() {

}// end E2

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

View raw message