cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r651415 - in /cayenne/main/trunk: docs/doc/src/main/resources/ framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/ framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/
Date Thu, 24 Apr 2008 20:54:40 GMT
Author: aadamchik
Date: Thu Apr 24 13:54:30 2008
New Revision: 651415

URL: http://svn.apache.org/viewvc?rev=651415&view=rev
Log:
CAY-1005 CM Qualifier (or Declared Qualifier) is not honoured in 100% cases

Modified:
    cayenne/main/trunk/docs/doc/src/main/resources/RELEASE-NOTES.txt
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/DataDomainQueryAction.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/CDOQualifiedEntitiesTest.java

Modified: cayenne/main/trunk/docs/doc/src/main/resources/RELEASE-NOTES.txt
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/docs/doc/src/main/resources/RELEASE-NOTES.txt?rev=651415&r1=651414&r2=651415&view=diff
==============================================================================
--- cayenne/main/trunk/docs/doc/src/main/resources/RELEASE-NOTES.txt (original)
+++ cayenne/main/trunk/docs/doc/src/main/resources/RELEASE-NOTES.txt Thu Apr 24 13:54:30 2008
@@ -46,6 +46,7 @@
 CAY-992 Modeler does not escape entity names
 CAY-998 ROP paginated lists must recover from server LRU query cache overflow
 CAY-1003 the paged queries in ROP can fail to fetch the subsequent pages if the client and
server are in different timezones
+CAY-1005 CM Qualifier (or Declared Qualifier) is not honoured in 100% cases
 CAY-1018 Enums fetched via SQLTemplate
 CAY-1020 Problem accessing toMany Set relationships on client.
 CAY-1028 NPE's in the Modeler for incomplete relationships

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/DataDomainQueryAction.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/DataDomainQueryAction.java?rev=651415&r1=651414&r2=651415&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/DataDomainQueryAction.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/access/DataDomainQueryAction.java
Thu Apr 24 13:54:30 2008
@@ -218,14 +218,21 @@
                 this.response = new GenericResponse(Collections.singletonList(targetRow));
                 return DONE;
             }
-            // a hack to prevent passing partial snapshots to ObjectResolver ... See
-            // CAY-724 for details.
-            else if (context != null
-                    && domain.getEntityResolver().lookupInheritanceTree(
-                            (ObjEntity) relationship.getTargetEntity()) == null) {
 
+            ObjEntity targetEntity = (ObjEntity) relationship.getTargetEntity();
+
+            // do not create a target hollow object for qualified entities or entities
+            // involved in inheritance, as the target object may be null even for non-null
+            // FK.
+            if (context != null
+                    && !isQualifiedEntity(targetEntity)
+                    && domain.getEntityResolver().lookupInheritanceTree(targetEntity)
== null) {
+
+                // prevent passing partial snapshots to ObjectResolver per CAY-724. Create
+                // a hollow object right here and skip object conversion downstream
                 this.noObjectConversion = true;
                 Object object = context.localObject(targetId, null);
+
                 this.response = new GenericResponse(Collections.singletonList(object));
                 return DONE;
             }
@@ -550,6 +557,23 @@
 
     public boolean isIteratedResult() {
         return false;
+    }
+
+    /**
+     * Returns true if the entity or its super entities have a limiting qualifier.
+     */
+    private boolean isQualifiedEntity(ObjEntity entity) {
+        if (entity.getDeclaredQualifier() != null) {
+            return true;
+        }
+
+        entity = entity.getSuperEntity();
+
+        if (entity == null) {
+            return false;
+        }
+
+        return isQualifiedEntity(entity);
     }
 
     abstract class ObjectConversionStrategy {

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/CDOQualifiedEntitiesTest.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/CDOQualifiedEntitiesTest.java?rev=651415&r1=651414&r2=651415&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/CDOQualifiedEntitiesTest.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/CDOQualifiedEntitiesTest.java
Thu Apr 24 13:54:30 2008
@@ -63,8 +63,7 @@
 
         insert1.setParameters(parameters1, parameters2);
         context.performQuery(insert1);
-        
-        
+
         SQLTemplate insert2 = new SQLTemplate(
                 Qualified2.class,
                 "insert into QUALIFIED2 (ID, NAME, DELETED, QUALIFIED1_ID) "
@@ -92,22 +91,66 @@
         parameters6.put("name", "OY4");
         parameters6.put("deleted", true);
         parameters6.put("q1id", 2);
-        
+
         insert2.setParameters(parameters3, parameters4, parameters5, parameters6);
         context.performQuery(insert2);
-        
-        
+
         SelectQuery rootSelect = new SelectQuery(Qualified1.class);
         List<Qualified1> roots = context.performQuery(rootSelect);
         assertEquals(1, roots.size());
-        
+
         Qualified1 root = roots.get(0);
         assertEquals("OX1", root.getName());
-        
+
         List<Qualified2> related = root.getQualified2s();
         assertEquals(1, related.size());
-        
+
         Qualified2 r = related.get(0);
         assertEquals("OY1", r.getName());
+    }
+
+    public void testReadToOne() throws Exception {
+        ObjectContext context = createDataContext();
+
+        // prepare data set...
+        SQLTemplate insert1 = new SQLTemplate(
+                Qualified1.class,
+                "insert into QUALIFIED1 (ID, NAME, DELETED) "
+                        + "values (#bind($id), #bind($name), #bind($deleted 'BOOLEAN'))");
+        Map<String, Object> parameters1 = new HashMap<String, Object>();
+        parameters1.put("id", 1);
+        parameters1.put("name", "OX1");
+        parameters1.put("deleted", null);
+
+        Map<String, Object> parameters2 = new HashMap<String, Object>();
+        parameters2.put("id", 2);
+        parameters2.put("name", "OX2");
+        parameters2.put("deleted", true);
+
+        insert1.setParameters(parameters1, parameters2);
+        context.performQuery(insert1);
+
+        SQLTemplate insert2 = new SQLTemplate(
+                Qualified2.class,
+                "insert into QUALIFIED2 (ID, NAME, DELETED, QUALIFIED1_ID) "
+                        + "values (#bind($id), #bind($name), #bind($deleted 'BOOLEAN'), #bind($q1id))");
+        Map<String, Object> parameters3 = new HashMap<String, Object>();
+        parameters3.put("id", 1);
+        parameters3.put("name", "OY1");
+        parameters3.put("deleted", null);
+        parameters3.put("q1id", 2);
+
+        insert2.setParameters(parameters3);
+        context.performQuery(insert2);
+
+        SelectQuery rootSelect = new SelectQuery(Qualified2.class);
+        List<Qualified2> roots = context.performQuery(rootSelect);
+        assertEquals(1, roots.size());
+
+        Qualified2 root = roots.get(0);
+        assertEquals("OY1", root.getName());
+
+        Qualified1 target = root.getQualified1();
+        assertNull("" + target, target);
     }
 }



Mime
View raw message