openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mik...@apache.org
Subject svn commit: r752663 - /openjpa/branches/1.2.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/ClassMapping.java
Date Wed, 11 Mar 2009 22:37:51 GMT
Author: mikedd
Date: Wed Mar 11 22:37:51 2009
New Revision: 752663

URL: http://svn.apache.org/viewvc?rev=752663&view=rev
Log:
OPENJPA-679. Committing Fay's patch

Modified:
    openjpa/branches/1.2.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/ClassMapping.java

Modified: openjpa/branches/1.2.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/ClassMapping.java
URL: http://svn.apache.org/viewvc/openjpa/branches/1.2.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/ClassMapping.java?rev=752663&r1=752662&r2=752663&view=diff
==============================================================================
--- openjpa/branches/1.2.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/ClassMapping.java
(original)
+++ openjpa/branches/1.2.x/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/ClassMapping.java
Wed Mar 11 22:37:51 2009
@@ -89,7 +89,6 @@
 
     // maps columns to joinables
     private final Map _joinables = Collections.synchronizedMap(new HashMap());
-    private boolean redoPrimaryKeyColumns = false;
 
     /**
      * Constructor. Supply described type and owning repository.
@@ -403,18 +402,15 @@
      */
     public Column[] getPrimaryKeyColumns() {
         if (getIdentityType() == ID_APPLICATION && isMapped()) {
-            if (_cols.length == 0 || redoPrimaryKeyColumns) {            
+            if (_cols.length == 0) {            
                 FieldMapping[] pks = getPrimaryKeyFieldMappings();
                 Collection cols = new ArrayList(pks.length);
                 Column[] fieldCols;
                 for (int i = 0; i < pks.length; i++) {
                     fieldCols = pks[i].getColumns();
                     if (fieldCols.length == 0) {
-                        // some pk columns depends on fk. At this moment, 
-                        // the fk may not contain complete information.
-                        // need to redo the primary key again later on
-                        redoPrimaryKeyColumns = true;
-                        continue;
+                        _cols = new Column[0];
+                        return _cols;
                     }
                     for (int j = 0; j < fieldCols.length; j++)
                         cols.add(fieldCols[j]);
@@ -820,8 +816,12 @@
         FieldMapping[] fms = getFieldMappings();
         for (int i = 0; i < fms.length; i++) {
             if (fms[i].getDefiningMetaData() == this) {
-                if (fms[i].getForeignKey() != null &&
-                    fms[i].getStrategy() instanceof RelationFieldStrategy) {
+                boolean fill =
+                    getMappingRepository().getMappingDefaults()
+                        .defaultMissingInfo();
+                ForeignKey fk = fms[i].getForeignKey();
+                if (fill && fk != null && 
+                    fk.getPrimaryKeyColumns().length == 0) { 
                     // set resolve mode to force this field mapping to be 
                     // resolved again. The need to resolve again occurs when 
                     // a primary key is a relation field with the foreign key
@@ -831,10 +831,9 @@
                     // field, the foreign key will be constructed. However, 
                     // the primary key of the parent entity may not have been 
                     // resolved yet, resulting in missing informaiton in the fk
-                    fms[i].setResolve(MODE_META); 
-
-                    // set strategy to null to force fk to be re-constructed
-                    fms[i].setStrategy(null, false); 
+                    fms[i].setResolve(MODE_META);
+                    fms[i].getStrategy().map(false);
+                 
                 }                
                 fms[i].resolve(MODE_MAPPING);
             }



Mime
View raw message