diff --git a/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/PersistenceMappingDefaults.java b/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/PersistenceMappingDefaults.java index c48f6fcfe..1a593d325 100644 --- a/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/PersistenceMappingDefaults.java +++ b/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/PersistenceMappingDefaults.java @@ -44,6 +44,8 @@ import serp.util.Strings; public class PersistenceMappingDefaults extends MappingDefaultsImpl { + private boolean _prependFieldNameToJoinTableInverseJoinColumns = true; + public PersistenceMappingDefaults() { setDefaultMissingInfo(true); setStoreEnumOrdinal(true); @@ -52,6 +54,24 @@ public class PersistenceMappingDefaults 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 @@ public class PersistenceMappingDefaults 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;