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.
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?