OPENJPA-705: Secondary table for Embdded field is to be looked up in the owner's secondary table.

git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@688919 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Pinaki Poddar 2008-08-25 23:28:31 +00:00
parent 36abd7cb62
commit 42f2f394fb
1 changed files with 12 additions and 3 deletions

View File

@ -153,11 +153,20 @@ public class FieldMappingInfo
public ForeignKey getJoin(final FieldMapping field, Table table, public ForeignKey getJoin(final FieldMapping field, Table table,
boolean adapt) { boolean adapt) {
// if we have no join columns defined, check class-level join // if we have no join columns defined, check class-level join
// if the given field is embedded then consider primary table of owner
List cols = getColumns(); List cols = getColumns();
if (cols.isEmpty()) if (cols.isEmpty()) {
cols = field.getDefiningMapping().getMappingInfo(). ClassMapping mapping;
if (field.isEmbedded() &&
field.getDeclaringMapping().getEmbeddingMapping() != null) {
mapping = field.getDeclaringMapping().getEmbeddingMapping()
.getFieldMapping().getDeclaringMapping();
} else {
mapping = field.getDefiningMapping();
}
cols = mapping.getMappingInfo().
getSecondaryTableJoinColumns(_tableName); getSecondaryTableJoinColumns(_tableName);
}
ForeignKeyDefaults def = new ForeignKeyDefaults() { ForeignKeyDefaults def = new ForeignKeyDefaults() {
public ForeignKey get(Table local, Table foreign, boolean inverse) { public ForeignKey get(Table local, Table foreign, boolean inverse) {
return field.getMappingRepository().getMappingDefaults(). return field.getMappingRepository().getMappingDefaults().