openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mark Struberg (JIRA)" <>
Subject [jira] [Reopened] (OPENJPA-2335) Constrained foreign key column value setting needs to be flexible
Date Sun, 03 Nov 2013 21:20:17 GMT


Mark Struberg reopened OPENJPA-2335:

      Assignee: Pinaki Poddar

The change seems broken, it makes a few of my apps blow up.

I do not really get the whole change. The bug description doesn't tell me why this change
got done and there is also no unit test for this change to tell me what you did like to fix.

I can give you my use case which is now broken

Car -> n Inspections
with @OrderColumn(name = "POSITION")

Car c = new Car();
Inspection i1 = new Inspection(1, c); //Inspection adds itself to car.inspections
Inspection i2 = new Inspection(2, c);

This currently blurps out with 

Caused by: <openjpa-2.3.0-r422266:1538090M fatal user error> org.apache.openjpa.persistence.InvalidStateException:
Attempt to set column "Inspection.POSITION" to two different values: (class java.lang.Integer)"1",
(class java.lang.Integer)"0" 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(

It seems that the @OrderColumn is the issue in this case. Your change looks fine for primary
keys, but OrderColumns and all other stuff which gets auto-managed by OpenJPA also use the
same code. 

Maybe we should only do these checks in case of real primary or foreign keys?

> Constrained foreign key column value setting needs to be flexible 
> ------------------------------------------------------------------
>                 Key: OPENJPA-2335
>                 URL:
>             Project: OpenJPA
>          Issue Type: Bug
>            Reporter: Pinaki Poddar
>            Assignee: Pinaki Poddar
>             Fix For: 2.3.0
> Should allow setting a column from default value to a non-default value. The logic had
a bug.

This message was sent by Atlassian JIRA

View raw message