AbstractMemberMetaData[] relatedMmds = mmd.getRelatedMemberMetaData(clr);
if (mmd.getJoinMetaData() != null || relatedMmds[0].getJoinMetaData() != null)
{
// N-1 bidirectional join table relation
// Add left outer join from {sourceTable}.ID to {joinTable}.ELEM_FK
DatastoreContainerObject joinTable =
storeMgr.getDatastoreContainerObject(relatedMmds[0]);
DatastoreElementContainer collTable = (DatastoreElementContainer)joinTable;
JavaTypeMapping selectMapping = collTable.getOwnerMapping();
SQLTable joinSqlTbl = null;
if (stmt.getPrimaryTable().getTable() != joinTable)
{
// Join to the join table
JavaTypeMapping referenceMapping = collTable.getElementMapping();
joinSqlTbl = stmt.leftOuterJoin(sourceSqlTbl,
sourceSqlTbl.getTable().getIdMapping(),
collTable, null, referenceMapping, null, tableGroupName);
}
else
{
// Main table of the statement is the join table so no need to join
joinSqlTbl = stmt.getPrimaryTable();
}
// Select the owner mapping of the join table
int[] colNumbers = stmt.select(joinSqlTbl, selectMapping, null);
stmtMapping.setColumnPositions(colNumbers);
}
// TODO Select fetch plan fields of this related object
}
else if (relationType == Relation.MANY_TO_ONE_UNI)
{
// Add left outer join from {sourceTable}.ID to {joinTable}.OWNER_FK
PersistableJoinTable joinTable = (PersistableJoinTable) storeMgr.getDatastoreContainerObject(mmd);
SQLTable joinSqlTbl = stmt.leftOuterJoin(sourceSqlTbl,
sourceSqlTbl.getTable().getIdMapping(),
joinTable, null, joinTable.getOwnerMapping(), null, tableGroupName);
int[] colNumbers = stmt.select(joinSqlTbl, joinTable.getRelatedMapping(), null);
stmtMapping.setColumnPositions(colNumbers);
// TODO Select fetch plan fields of this related object
}
}
if (mappingDefinition != null)