cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From and...@apache.org
Subject svn commit: r817829 - in /cayenne/main/trunk: docs/doc/src/main/resources/ framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/ framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/testdo/db1/auto/ framework/cayen...
Date Tue, 22 Sep 2009 20:33:08 GMT
Author: andrey
Date: Tue Sep 22 20:33:06 2009
New Revision: 817829

URL: http://svn.apache.org/viewvc?rev=817829&view=rev
Log:
CAY-1278 Project with cross-datamap flattenned relationships fails to load

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/map/Entity.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/MapLoader.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/ObjRelationship.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/testdo/db1/auto/_CrossdbM1E1.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/resources/map-db1.map.xml

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=817829&r1=817828&r2=817829&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 Tue Sep 22 20:33:06 2009
@@ -49,6 +49,7 @@
 CAY-1274 CreateTableToDb should not create existing AUTO_PK_SUPPORT
 CAY-1275 Merge set-not-null to Oracle through modeler fails if auto adapter is set
 CAY-1277 Prefetching may cause a root object to got from COMMITTED to MODIFIED state
+CAY-1278 Project with cross-datamap flattenned relationships fails to load
 
 ----------------------------------
 Release: 3.0M6

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/Entity.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/Entity.java?rev=817829&r1=817828&r2=817829&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/Entity.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/Entity.java
Tue Sep 22 20:33:06 2009
@@ -290,6 +290,7 @@
      * @deprecated since 3.0 use {@link #lastPathComponent(Expression, Map)} method that
      *             supports aliases.
      */
+    @Deprecated
     public Object lastPathComponent(Expression path) {
 
         PathComponent<Attribute, Relationship> last = lastPathComponent(
@@ -403,7 +404,7 @@
 
         public CayenneMapEntry next() {
             String pathComp = toks.nextToken();
-
+            
             // see if this is an attribute
             Attribute attr = currentEnt.getAttribute(pathComp);
             if (attr != null) {
@@ -422,7 +423,9 @@
             Relationship rel = currentEnt.getRelationship(pathComp);
             if (rel != null) {
                 currentEnt = rel.getTargetEntity();
-                return rel;
+                if (currentEnt != null || !toks.hasMoreTokens()) { //otherwise an exception
will be thrown
+                    return rel;
+                }
             }
 
             // build error message

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/MapLoader.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/MapLoader.java?rev=817829&r1=817828&r2=817829&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/MapLoader.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/MapLoader.java
Tue Sep 22 20:33:06 2009
@@ -1078,7 +1078,7 @@
         objRelationship.setUsedForLocking(TRUE
                 .equalsIgnoreCase(atts.getValue("", "lock")));
         objRelationship
-                .setDbRelationshipPath((atts.getValue("", "db-relationship-path")));
+                .setDeferredDbRelationshipPath((atts.getValue("", "db-relationship-path")));
         objRelationship.setCollectionType(collectionType);
         objRelationship.setMapKey(mapKey);
         source.addRelationship(objRelationship);

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/ObjRelationship.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/ObjRelationship.java?rev=817829&r1=817828&r2=817829&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/ObjRelationship.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/map/ObjRelationship.java
Tue Sep 22 20:33:06 2009
@@ -53,6 +53,12 @@
     protected boolean usedForLocking;
 
     protected List<DbRelationship> dbRelationships = new ArrayList<DbRelationship>(2);
+    
+    /**
+     * Db-relationships path that is set but not yet parsed (turned into List<DbRelationship>)
+     * Used during map loading
+     */
+    String deferredPath;
 
     /**
      * Stores the type of collection mapped by a to-many relationship. Null for to-one
@@ -227,6 +233,7 @@
      * Returns an immutable list of underlying DbRelationships.
      */
     public List<DbRelationship> getDbRelationships() {
+        refreshFromDeferredPath();
         return Collections.unmodifiableList(dbRelationships);
     }
 
@@ -234,6 +241,7 @@
      * Appends a DbRelationship to the existing list of DbRelationships.
      */
     public void addDbRelationship(DbRelationship dbRel) {
+        refreshFromDeferredPath();
         if (dbRel.getName() == null) {
             throw new IllegalArgumentException("DbRelationship has no name");
         }
@@ -265,6 +273,7 @@
      * Removes the relationship <code>dbRel</code> from the list of relationships.
      */
     public void removeDbRelationship(DbRelationship dbRel) {
+        refreshFromDeferredPath();
         if (dbRelationships.remove(dbRel)) {
             this.recalculateReadOnlyValue();
             this.recalculateToManyValue();
@@ -272,6 +281,7 @@
     }
 
     public void clearDbRelationships() {
+        deferredPath = null;
         this.dbRelationships.clear();
         this.readOnly = false;
         this.toMany = false;
@@ -389,12 +399,14 @@
      * @return flag indicating if the relationship is read only or not
      */
     public boolean isReadOnly() {
+        refreshFromDeferredPath();
         recalculateReadOnlyValue();
         return readOnly;
     }
 
     @Override
     public boolean isToMany() {
+        refreshFromDeferredPath();
         recalculateToManyValue();
         return super.isToMany();
     }
@@ -466,6 +478,8 @@
      * @since 1.1
      */
     public String getDbRelationshipPath() {
+        refreshFromDeferredPath();
+        
         // build path on the fly
         if (getDbRelationships().isEmpty()) {
             return null;
@@ -530,6 +544,26 @@
             refreshFromPath(relationshipPath);
         }
     }
+    
+    /**
+     * Sets relationship path, but does not trigger its conversion to List<DbRelationship>
+     * For internal purposes, primarily datamap loading
+     */
+    void setDeferredDbRelationshipPath(String relationshipPath) {
+        if (!Util.nullSafeEquals(getDbRelationshipPath(), relationshipPath)) {
+            deferredPath = relationshipPath;
+        }
+    }
+    
+    /**
+     * Loads path from "deferredPath" variable (if specified)
+     */
+    synchronized void refreshFromDeferredPath() {
+        if (deferredPath != null) {
+            refreshFromPath(deferredPath);
+            deferredPath = null;
+        }
+    }
 
     /**
      * Returns dot-separated path over DbRelationships, only including components that

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/testdo/db1/auto/_CrossdbM1E1.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/testdo/db1/auto/_CrossdbM1E1.java?rev=817829&r1=817828&r2=817829&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/testdo/db1/auto/_CrossdbM1E1.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/java/org/apache/cayenne/testdo/db1/auto/_CrossdbM1E1.java
Tue Sep 22 20:33:06 2009
@@ -2,14 +2,20 @@
 
 import java.util.List;
 
-/** Class _CrossdbM1E1 was generated by Cayenne.
-  * It is probably a good idea to avoid changing this class manually, 
-  * since it may be overwritten next time code is regenerated. 
-  * If you need to make any customizations, please use subclass. 
-  */
-public class _CrossdbM1E1 extends org.apache.cayenne.CayenneDataObject {
+import org.apache.cayenne.CayenneDataObject;
+import org.apache.cayenne.testdo.db2.CrossdbM2E1;
+import org.apache.cayenne.testdo.db2.CrossdbM2E2;
+
+/**
+ * Class _CrossdbM1E1 was generated by Cayenne.
+ * It is probably a good idea to avoid changing this class manually,
+ * since it may be overwritten next time code is regenerated.
+ * If you need to make any customizations, please use subclass.
+ */
+public abstract class _CrossdbM1E1 extends CayenneDataObject {
 
     public static final String NAME_PROPERTY = "name";
+    public static final String FLATTENED_PROPERTY = "flattened";
     public static final String LIST_OF_M2E2_PROPERTY = "listOfM2E2";
 
     public static final String ID_PK_COLUMN = "ID";
@@ -20,17 +26,29 @@
     public String getName() {
         return (String)readProperty("name");
     }
-    
-    
-    public void addToListOfM2E2(org.apache.cayenne.testdo.db2.CrossdbM2E2 obj) {
+
+    public void addToFlattened(CrossdbM2E1 obj) {
+        addToManyTarget("flattened", obj, true);
+    }
+    public void removeFromFlattened(CrossdbM2E1 obj) {
+        removeToManyTarget("flattened", obj, true);
+    }
+    @SuppressWarnings("unchecked")
+    public List<CrossdbM2E1> getFlattened() {
+        return (List<CrossdbM2E1>)readProperty("flattened");
+    }
+
+
+    public void addToListOfM2E2(CrossdbM2E2 obj) {
         addToManyTarget("listOfM2E2", obj, true);
     }
-    public void removeFromListOfM2E2(org.apache.cayenne.testdo.db2.CrossdbM2E2 obj) {
+    public void removeFromListOfM2E2(CrossdbM2E2 obj) {
         removeToManyTarget("listOfM2E2", obj, true);
     }
-    public List getListOfM2E2() {
-        return (List)readProperty("listOfM2E2");
+    @SuppressWarnings("unchecked")
+    public List<CrossdbM2E2> getListOfM2E2() {
+        return (List<CrossdbM2E2>)readProperty("listOfM2E2");
     }
-    
-    
+
+
 }

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/resources/map-db1.map.xml
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/resources/map-db1.map.xml?rev=817829&r1=817828&r2=817829&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/resources/map-db1.map.xml
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/test/resources/map-db1.map.xml
Tue Sep 22 20:33:06 2009
@@ -14,5 +14,6 @@
 	<db-relationship name="listOfM2E2" source="CROSSDB_M1E1" target="CROSSDB_M2E2" toMany="true">
 		<db-attribute-pair source="ID" target="M1E1_ID"/>
 	</db-relationship>
+	<obj-relationship name="flattened" source="CrossdbM1E1" target="CrossdbM2E1" deleteRule="Deny"
db-relationship-path="listOfM2E2.toM2E1"/>
 	<obj-relationship name="listOfM2E2" source="CrossdbM1E1" target="CrossdbM2E2" db-relationship-path="listOfM2E2"/>
 </data-map>



Mime
View raw message