openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From awh...@apache.org
Subject svn commit: r482737 - /incubator/openjpa/trunk/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/PersistenceMappingDefaults.java
Date Tue, 05 Dec 2006 18:54:48 GMT
Author: awhite
Date: Tue Dec  5 10:54:46 2006
New Revision: 482737

URL: http://svn.apache.org/viewvc?view=rev&rev=482737
Log:
Correct bug in our default for the name of an inverse join column within a
join table.  Added configurable property for users to retain the old defaulting
for compatibility if desired.


Modified:
    incubator/openjpa/trunk/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/PersistenceMappingDefaults.java

Modified: incubator/openjpa/trunk/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/PersistenceMappingDefaults.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/PersistenceMappingDefaults.java?view=diff&rev=482737&r1=482736&r2=482737
==============================================================================
--- incubator/openjpa/trunk/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/PersistenceMappingDefaults.java
(original)
+++ incubator/openjpa/trunk/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/PersistenceMappingDefaults.java
Tue Dec  5 10:54:46 2006
@@ -44,6 +44,8 @@
 public class PersistenceMappingDefaults
     extends MappingDefaultsImpl {
 
+    private boolean _prependFieldNameToJoinTableInverseJoinColumns = true;
+
     public PersistenceMappingDefaults() {
         setDefaultMissingInfo(true);
         setStoreEnumOrdinal(true);
@@ -52,6 +54,24 @@
         setDiscriminatorColumnName("DTYPE");
     }
 
+    /**
+     * Whether to prepend the field name to the default name of inverse join
+     * columns within join tables.  Defaults to true per spec, but set to false
+     * for compatibility with older versions of OpenJPA.
+     */
+    public boolean getPrependFieldNameToJoinTableInverseJoinColumns() {
+        return _prependFieldNameToJoinTableInverseJoinColumns;
+    }
+
+    /**
+     * Whether to prepend the field name to the default name of inverse join
+     * columns within join tables.  Defaults to true per spec, but set to false
+     * for compatibility with older versions of OpenJPA.
+     */
+    public void setPrependFieldNameToJoinTableInverseJoinColumns(boolean val) {
+        _prependFieldNameToJoinTableInverseJoinColumns = val;
+    }
+
     @Override
     public Object getStrategy(Version vers, boolean adapt) {
         Object strat = super.getStrategy(vers, adapt);
@@ -141,9 +161,10 @@
         Table local, Table foreign, Column col, Object target, boolean inverse,
         int pos, int cols) {
         // if this is a non-inverse collection element key, it must be in
-        // a join table; jpa says to use the target column name,
-        // which is the default
-        if (!inverse && vm == vm.getFieldMapping().getElement()
+        // a join table: if we're not prepending the field name, leave the
+        // default
+        if (!_prependFieldNameToJoinTableInverseJoinColumns && !inverse 
+            && vm == vm.getFieldMapping().getElement()
             && vm.getFieldMapping().getTypeCode() != JavaTypes.MAP)
             return;
 



Mime
View raw message