Default name fix.

git-svn-id: https://svn.apache.org/repos/asf/incubator/openjpa/trunk@482775 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
A. Abram White 2006-12-05 20:49:11 +00:00
parent d5fb9486ba
commit ee33aa7af3
1 changed files with 8 additions and 4 deletions

View File

@ -160,18 +160,22 @@ public class PersistenceMappingDefaults
public void populateForeignKeyColumn(ValueMapping vm, String name,
Table local, Table foreign, Column col, Object target, boolean inverse,
int pos, int cols) {
boolean elem = vm == vm.getFieldMapping().getElement()
&& vm.getFieldMapping().getTypeCode() != JavaTypes.MAP;
// if this is a non-inverse collection element key, it must be in
// 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)
if (!_prependFieldNameToJoinTableInverseJoinColumns && !inverse && elem)
return;
// otherwise jpa always uses <field>_<pkcol> for column name, even
// when only one col
if (target instanceof Column)
if (target instanceof Column) {
if (elem)
name = vm.getFieldMapping().getName();
col.setName(name + "_" + ((Column) target).getName());
}
}
@Override