cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r1404794 - /cayenne/main/branches/STABLE-3.1/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/DataDomainQueryAction.java
Date Thu, 01 Nov 2012 21:59:33 GMT
Author: aadamchik
Date: Thu Nov  1 21:59:32 2012
New Revision: 1404794

URL: http://svn.apache.org/viewvc?rev=1404794&view=rev
Log:
CAY-1751 FK pointing to an UNIQUE field. Problems to insert registers

(cherry picked from commit 81d2af9059f093f16f335f58f15bf2688b267a91)

Modified:
    cayenne/main/branches/STABLE-3.1/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/DataDomainQueryAction.java

Modified: cayenne/main/branches/STABLE-3.1/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/DataDomainQueryAction.java
URL: http://svn.apache.org/viewvc/cayenne/main/branches/STABLE-3.1/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/DataDomainQueryAction.java?rev=1404794&r1=1404793&r2=1404794&view=diff
==============================================================================
--- cayenne/main/branches/STABLE-3.1/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/DataDomainQueryAction.java
(original)
+++ cayenne/main/branches/STABLE-3.1/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/DataDomainQueryAction.java
Thu Nov  1 21:59:32 2012
@@ -40,6 +40,7 @@ import org.apache.cayenne.QueryResponse;
 import org.apache.cayenne.cache.QueryCache;
 import org.apache.cayenne.cache.QueryCacheEntryFactory;
 import org.apache.cayenne.map.DataMap;
+import org.apache.cayenne.map.DbEntity;
 import org.apache.cayenne.map.DbRelationship;
 import org.apache.cayenne.map.LifecycleEvent;
 import org.apache.cayenne.map.ObjRelationship;
@@ -194,11 +195,23 @@ class DataDomainQueryAction implements Q
             ObjRelationship relationship = relationshipQuery.getRelationship(domain
                     .getEntityResolver());
 
-            // check if we can derive target PK from FK... this implies that the
-            // relationship is to-one
+            // check if we can derive target PK from FK...
             if (relationship.isSourceIndependentFromTargetChange()) {
                 return !DONE;
             }
+            
+            // we can assume that there is one and only one DbRelationship as
+            // we previously checked that "!isSourceIndependentFromTargetChange"
+            DbRelationship dbRelationship = relationship.getDbRelationships().get(0);
+            
+            // FK pointing to a unique field that is a 'fake' PK (CAY-1751)...
+            // It is not sufficient to generate target ObjectId.
+            DbEntity targetEntity = (DbEntity) dbRelationship.getTargetEntity();
+            if (dbRelationship.getJoins().size() < targetEntity
+                    .getPrimaryKeys().size()) {
+                return !DONE;
+            }
+            
 
             if (cache == null) {
                 return !DONE;
@@ -209,9 +222,6 @@ class DataDomainQueryAction implements Q
                 return !DONE;
             }
 
-            // we can assume that there is one and only one DbRelationship as
-            // we previously checked that "!isSourceIndependentFromTargetChange"
-            DbRelationship dbRelationship = relationship.getDbRelationships().get(0);
 
             ObjectId targetId = sourceRow.createTargetObjectId(
                     relationship.getTargetEntityName(),



Mime
View raw message