openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hthom...@apache.org
Subject svn commit: r1709203 - in /openjpa/branches/2.2.x: ./ openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/ openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/merge/
Date Sat, 17 Oct 2015 18:35:00 GMT
Author: hthomann
Date: Sat Oct 17 18:34:59 2015
New Revision: 1709203

URL: http://svn.apache.org/viewvc?rev=1709203&view=rev
Log:
OPENJPA-2603: Merging an unmanaged entity multiple (3) times leads to an exception.  Merged
2.1.x changes to 2.2.x.

Added:
    openjpa/branches/2.2.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/merge/LineItem.java
      - copied unchanged from r1709201, openjpa/branches/2.1.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/merge/LineItem.java
    openjpa/branches/2.2.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/merge/LineItemPK.java
      - copied unchanged from r1709201, openjpa/branches/2.1.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/merge/LineItemPK.java
    openjpa/branches/2.2.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/merge/Order.java
      - copied unchanged from r1709201, openjpa/branches/2.1.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/merge/Order.java
    openjpa/branches/2.2.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/merge/TestMultipleMerge.java
      - copied unchanged from r1709201, openjpa/branches/2.1.x/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/merge/TestMultipleMerge.java
Modified:
    openjpa/branches/2.2.x/   (props changed)
    openjpa/branches/2.2.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/RelationToManyInverseKeyFieldStrategy.java

Propchange: openjpa/branches/2.2.x/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sat Oct 17 18:34:59 2015
@@ -1,5 +1,5 @@
 /openjpa/branches/1.0.x:736493
 /openjpa/branches/2.0.x:1484136,1484287,1504611
-/openjpa/branches/2.1.x:1415379,1415398,1469090,1469949,1484300,1484313,1485010,1505837,1513249,1517838,1529241,1530146,1533218,1533280,1539188,1569528,1575444,1591536,1614935,1636464,1648430,1655218,1662610,1673300,1673491,1686894
+/openjpa/branches/2.1.x:1415379,1415398,1469090,1469949,1484300,1484313,1485010,1505837,1513249,1517838,1529241,1530146,1533218,1533280,1539188,1569528,1575444,1591536,1614935,1636464,1648430,1655218,1662610,1673300,1673491,1686894,1709201
 /openjpa/branches/2.2.1.x:1415367,1415413,1415425,1469408,1470097,1484320,1484322,1491895,1504719,1529267,1529340,1530347,1531176,1533222,1539193,1584153,1648450,1651808,1686910
 /openjpa/trunk:1416742,1420324,1430117,1431649,1436957,1436960,1448662,1448796,1451369,1456574,1456614,1459091,1461833,1469646,1469649,1469652,1504282,1558594,1600682,1600757,1603251,1626287,1632647

Modified: openjpa/branches/2.2.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/RelationToManyInverseKeyFieldStrategy.java
URL: http://svn.apache.org/viewvc/openjpa/branches/2.2.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/RelationToManyInverseKeyFieldStrategy.java?rev=1709203&r1=1709202&r2=1709203&view=diff
==============================================================================
--- openjpa/branches/2.2.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/RelationToManyInverseKeyFieldStrategy.java
(original)
+++ openjpa/branches/2.2.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/strats/RelationToManyInverseKeyFieldStrategy.java
Sat Oct 17 18:34:59 2015
@@ -270,7 +270,15 @@ public abstract class RelationToManyInve
         ValueMapping elem = field.getElementMapping();
         ColumnIO io = elem.getColumnIO();
         ForeignKey fk = elem.getForeignKey();
-        if (!elem.getUseClassCriteria() && io.isAnyUpdatable(fk, true)) { 
+
+        //OJ-2603: Don't null an FK which is also a PK in the referencing object.
+        boolean containsPK = false;
+        Column[] cols = fk.getColumns();
+        for (int i = 0; i < cols.length && !containsPK; i++){
+            containsPK= cols[i].isPrimaryKey();
+        }
+
+        if (!elem.getUseClassCriteria() && io.isAnyUpdatable(fk, true) &&
!containsPK) { 
             assertInversable();
             Row row = rm.getAllRows(fk.getTable(), Row.ACTION_UPDATE);
             row.setForeignKey(fk, io, null);



Mime
View raw message