mirror of https://github.com/apache/openjpa.git
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. git-svn-id: https://svn.apache.org/repos/asf/incubator/openjpa/trunk@482737 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
a836ea3f34
commit
87dc2aad7c
|
@ -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;
|
||||
|
||||
|
|
Loading…
Reference in New Issue