cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r1397185 - in /cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src: main/java/org/apache/cayenne/access/DbArcId.java main/java/org/apache/cayenne/access/FlattenedArcKey.java test/java/org/apache/cayenne/access/DbArcIdTest.java
Date Thu, 11 Oct 2012 17:31:48 GMT
Author: aadamchik
Date: Thu Oct 11 17:31:48 2012
New Revision: 1397185

URL: http://svn.apache.org/viewvc?rev=1397185&view=rev
Log:
CAY-1747 New algorithm for tracking changes to DbEntities underlying flattened attributes
and relationships

cleaning up DbArcId - removing redundant constructor arg

Modified:
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/DbArcId.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/FlattenedArcKey.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DbArcIdTest.java

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/DbArcId.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/DbArcId.java?rev=1397185&r1=1397184&r2=1397185&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/DbArcId.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/DbArcId.java
Thu Oct 11 17:31:48 2012
@@ -17,17 +17,21 @@ final class DbArcId {
 
     private int hashCode;
 
-    private DbEntity entity;
     private ObjectId sourceId;
     private DbRelationship incomingArc;
 
-    DbArcId(DbEntity entity, ObjectId sourceId, DbRelationship incomingArc) {
-        this.entity = entity;
+    private DbEntity entity;
+
+    DbArcId(ObjectId sourceId, DbRelationship incomingArc) {
         this.sourceId = sourceId;
         this.incomingArc = incomingArc;
     }
 
     DbEntity getEntity() {
+        if (entity == null) {
+            entity = (DbEntity) incomingArc.getTargetEntity();
+        }
+
         return entity;
     }
 

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/FlattenedArcKey.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/FlattenedArcKey.java?rev=1397185&r1=1397184&r2=1397185&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/FlattenedArcKey.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/FlattenedArcKey.java
Thu Oct 11 17:31:48 2012
@@ -78,8 +78,8 @@ final class FlattenedArcKey {
                             + dbRelationships.get(1));
         }
 
-        id1 = new DbArcId((DbEntity) r1.getTargetEntity(), sourceId, r1);
-        id2 = new DbArcId(id1.getEntity(), destinationId, r2);
+        id1 = new DbArcId(sourceId, r1);
+        id2 = new DbArcId(destinationId, r2);
     }
 
     /**

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DbArcIdTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DbArcIdTest.java?rev=1397185&r1=1397184&r2=1397185&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DbArcIdTest.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/access/DbArcIdTest.java
Thu Oct 11 17:31:48 2012
@@ -3,52 +3,47 @@ package org.apache.cayenne.access;
 import junit.framework.TestCase;
 
 import org.apache.cayenne.ObjectId;
-import org.apache.cayenne.map.DbEntity;
 import org.apache.cayenne.map.DbRelationship;
 
 public class DbArcIdTest extends TestCase {
 
     public void testHashCode() {
 
-        DbEntity e = new DbEntity("X");
-
-        DbArcId id1 = new DbArcId(e, new ObjectId("x", "k", "v"),
+        DbArcId id1 = new DbArcId(new ObjectId("x", "k", "v"),
                 new DbRelationship("r1"));
         int h1 = id1.hashCode();
         assertEquals(h1, id1.hashCode());
         assertEquals(h1, id1.hashCode());
 
-        DbArcId id1_eq = new DbArcId(e, new ObjectId("x", "k", "v"),
+        DbArcId id1_eq = new DbArcId(new ObjectId("x", "k", "v"),
                 new DbRelationship("r1"));
         assertEquals(h1, id1_eq.hashCode());
 
-        DbArcId id2 = new DbArcId(e, new ObjectId("x", "k", "v"),
+        DbArcId id2 = new DbArcId(new ObjectId("x", "k", "v"),
                 new DbRelationship("r2"));
         assertFalse(h1 == id2.hashCode());
 
-        DbArcId id3 = new DbArcId(e, new ObjectId("y", "k", "v"),
+        DbArcId id3 = new DbArcId(new ObjectId("y", "k", "v"),
                 new DbRelationship("r1"));
         assertFalse(h1 == id3.hashCode());
     }
 
     public void testEquals() {
 
-        DbEntity e = new DbEntity("X");
-
-        DbArcId id1 = new DbArcId(e, new ObjectId("x", "k", "v"),
+        DbArcId id1 = new DbArcId(new ObjectId("x", "k", "v"),
                 new DbRelationship("r1"));
         assertTrue(id1.equals(id1));
 
-        DbArcId id1_eq = new DbArcId(e, new ObjectId("x", "k", "v"),
+        DbArcId id1_eq = new DbArcId(new ObjectId("x", "k", "v"),
                 new DbRelationship("r1"));
         assertTrue(id1.equals(id1_eq));
         assertTrue(id1_eq.equals(id1));
 
-        DbArcId id2 = new DbArcId(e, new ObjectId("x", "k", "v"),
+        DbArcId id2 = new DbArcId(new ObjectId("x", "k", "v"),
                 new DbRelationship("r2"));
         assertFalse(id1.equals(id2));
 
-        DbArcId id3 = new DbArcId(e, new ObjectId("y", "k", "v"),
+        DbArcId id3 = new DbArcId(new ObjectId("y", "k", "v"),
                 new DbRelationship("r1"));
         assertFalse(id1.equals(id3));
 



Mime
View raw message