cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject [4/4] cayenne git commit: CAY-2146 Vertical inheritance: record still inserted into parent db table when child validation fails
Date Sun, 27 Nov 2016 13:42:23 GMT
CAY-2146 Vertical inheritance: record still inserted into parent db table when child validation
fails

* no changes; minor refactoring for clarity


Project: http://git-wip-us.apache.org/repos/asf/cayenne/repo
Commit: http://git-wip-us.apache.org/repos/asf/cayenne/commit/0e3a07c1
Tree: http://git-wip-us.apache.org/repos/asf/cayenne/tree/0e3a07c1
Diff: http://git-wip-us.apache.org/repos/asf/cayenne/diff/0e3a07c1

Branch: refs/heads/master
Commit: 0e3a07c1ec1f97938b7d0d9c67512dbd4a75f86c
Parents: b217313
Author: Andrus Adamchik <andrus@objectstyle.com>
Authored: Sun Nov 27 16:36:44 2016 +0300
Committer: Andrus Adamchik <andrus@objectstyle.com>
Committed: Sun Nov 27 16:36:44 2016 +0300

----------------------------------------------------------------------
 .../org/apache/cayenne/CayenneDataObject.java   | 29 +++++++++++---------
 .../cayenne/access/VerticalInheritanceIT.java   |  3 --
 2 files changed, 16 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cayenne/blob/0e3a07c1/cayenne-server/src/main/java/org/apache/cayenne/CayenneDataObject.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/CayenneDataObject.java b/cayenne-server/src/main/java/org/apache/cayenne/CayenneDataObject.java
index d61b33f..3b7a5be 100644
--- a/cayenne-server/src/main/java/org/apache/cayenne/CayenneDataObject.java
+++ b/cayenne-server/src/main/java/org/apache/cayenne/CayenneDataObject.java
@@ -19,17 +19,6 @@
 
 package org.apache.cayenne;
 
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.lang.reflect.Array;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
 import org.apache.cayenne.map.DbAttribute;
 import org.apache.cayenne.map.DbJoin;
 import org.apache.cayenne.map.DbRelationship;
@@ -43,6 +32,17 @@ import org.apache.cayenne.validation.BeanValidationFailure;
 import org.apache.cayenne.validation.ValidationFailure;
 import org.apache.cayenne.validation.ValidationResult;
 
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.lang.reflect.Array;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
 /**
  * A default implementation of DataObject interface. It is normally used as a
  * superclass of Cayenne persistent objects.
@@ -663,8 +663,11 @@ public class CayenneDataObject extends PersistentObject implements DataObject,
V
 			// skip db relationships that we can't validate or that can't be invalid here
 			// can't handle paths longer than two db relationships
 			// see ObjRelationship.recalculateReadOnlyValue() for more info
-			if (dbRels.size() == 1 && relationship.isSourceIndependentFromTargetChange() ||
-					dbRels.size() > 1 && (relationship.isToMany() || relationship.isReadOnly()))
{
+			if (dbRels.size() == 1 && relationship.isSourceIndependentFromTargetChange())
{
+				continue;
+			}
+
+			if (dbRels.size() > 1 && (relationship.isToMany() || relationship.isReadOnly()))
{
 				continue;
 			}
 

http://git-wip-us.apache.org/repos/asf/cayenne/blob/0e3a07c1/cayenne-server/src/test/java/org/apache/cayenne/access/VerticalInheritanceIT.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/access/VerticalInheritanceIT.java
b/cayenne-server/src/test/java/org/apache/cayenne/access/VerticalInheritanceIT.java
index 5a1e957..6abf403 100644
--- a/cayenne-server/src/test/java/org/apache/cayenne/access/VerticalInheritanceIT.java
+++ b/cayenne-server/src/test/java/org/apache/cayenne/access/VerticalInheritanceIT.java
@@ -202,9 +202,6 @@ public class VerticalInheritanceIT extends ServerCase {
         IvSub3 sub3 = context.newObject(IvSub3.class);
         sub3.setName("XyZX");
 		context.commitChanges();
-
-        assertEquals(1, ivRootTable.getRowCount());
-        assertEquals(1, ivSub3Table.getRowCount());
     }
 
 	/**


Mime
View raw message