cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r577313 - /cayenne/main/trunk/framework/cayenne-jpa-unpublished/src/main/java/org/apache/cayenne/jpa/bridge/DataMapConverter.java
Date Wed, 19 Sep 2007 14:32:09 GMT
Author: aadamchik
Date: Wed Sep 19 07:32:09 2007
New Revision: 577313

URL: http://svn.apache.org/viewvc?rev=577313&view=rev
Log:
CAY-860 JPA  no joins created for to-many relationship
(reafctoring code; no algorithm changes yet)

Modified:
    cayenne/main/trunk/framework/cayenne-jpa-unpublished/src/main/java/org/apache/cayenne/jpa/bridge/DataMapConverter.java

Modified: cayenne/main/trunk/framework/cayenne-jpa-unpublished/src/main/java/org/apache/cayenne/jpa/bridge/DataMapConverter.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jpa-unpublished/src/main/java/org/apache/cayenne/jpa/bridge/DataMapConverter.java?rev=577313&r1=577312&r2=577313&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jpa-unpublished/src/main/java/org/apache/cayenne/jpa/bridge/DataMapConverter.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jpa-unpublished/src/main/java/org/apache/cayenne/jpa/bridge/DataMapConverter.java
Wed Sep 19 07:32:09 2007
@@ -52,6 +52,7 @@
 import org.apache.cayenne.map.DbEntity;
 import org.apache.cayenne.map.DbJoin;
 import org.apache.cayenne.map.DbRelationship;
+import org.apache.cayenne.map.Entity;
 import org.apache.cayenne.map.EntityListener;
 import org.apache.cayenne.map.ObjAttribute;
 import org.apache.cayenne.map.ObjEntity;
@@ -421,8 +422,7 @@
                         + jpaJoin.getReferencedColumnName());
             }
 
-            ObjRelationship objRelationship = (ObjRelationship) targetPath.getObject();
-            DataMap dataMap = objRelationship.getSourceEntity().getDataMap();
+            DbRelationship dbRelationship = (DbRelationship) targetPath.getObject();
 
             // add FK
             DbAttribute src = new DbAttribute(jpaJoin.getName());
@@ -433,14 +433,10 @@
             src.setMaxLength(jpaTargetId.getColumn().getLength());
             src.setType(jpaTargetId.getDefaultJdbcType());
 
-            DbEntity srcEntity = dataMap.getDbEntity(jpaJoin.getTable());
+            Entity srcEntity = dbRelationship.getSourceEntity();
             srcEntity.addAttribute(src);
 
             // add join
-            DbRelationship dbRelationship = (DbRelationship) objRelationship
-                    .getDbRelationships()
-                    .get(0);
-
             DbRelationship reverseRelationship = dbRelationship.getReverseRelationship();
             if (reverseRelationship == null) {
                 reverseRelationship = dbRelationship.createReverseRelationship();
@@ -454,7 +450,7 @@
 
             dbRelationship.addJoin(join);
             reverseRelationship.addJoin(reverseJoin);
-
+            
             return false;
         }
     }
@@ -580,10 +576,7 @@
 
             cayenneRelationship.setTargetEntityName(jpaTargetEntity.getName());
 
-            // TODO: db relationship should probably be created when the first join is
-            // created...
             DbEntity cayenneSrcDbEntity = cayenneSrcEntity.getDbEntity();
-
             DbEntity cayenneTargetDbEntity = cayenneSrcEntity.getDataMap().getDbEntity(
                     jpaTargetEntity.getTable().getName());
             if (cayenneTargetDbEntity == null) {
@@ -599,7 +592,7 @@
             cayenneSrcDbEntity.addRelationship(dbRelationship);
             cayenneRelationship.addDbRelationship(dbRelationship);
 
-            return cayenneRelationship;
+            return dbRelationship;
         }
     }
 



Mime
View raw message