// TODO Cater for more than one related field
JavaTypeMapping refMapping = targetTable.getMemberMapping(relatedMmds[0]);
JavaTypeMapping selectMapping = targetTable.getIDMapping();
DatastoreIdentifier targetTableIdentifier =
srm.getIdentifierFactory().newIdentifier(IdentifierType.TABLE, "RELATED" + mmd.getAbsoluteFieldNumber());
LogicSetExpression targetTe = qs.newTableExpression(targetTable, targetTableIdentifier);
return new ObjectExpression(qs, this, te, refMapping, targetTe, selectMapping);
}
else if (relationType == Relation.MANY_TO_ONE_BI)
{
AbstractMemberMetaData[] relatedMmds = mmd.getRelatedMemberMetaData(clr);
// TODO Cater for more than one related field
if (mmd.getJoinMetaData() != null || relatedMmds[0].getJoinMetaData() != null)
{
// Join table relation - only allows for Collection/Array
// Create an expression this table to the join table on the element id, selecting the owner id
DatastoreContainerObject targetTable = srm.getDatastoreContainerObject(relatedMmds[0]);
JavaTypeMapping refMapping = null;
JavaTypeMapping selectMapping = null;
DatastoreElementContainer elementTable = (DatastoreElementContainer)targetTable;
refMapping = elementTable.getElementMapping();
selectMapping = elementTable.getOwnerMapping();
DatastoreIdentifier targetTableIdentifier =
srm.getIdentifierFactory().newIdentifier(IdentifierType.TABLE, "JOINTABLE" + mmd.getAbsoluteFieldNumber());
LogicSetExpression targetTe = qs.newTableExpression(targetTable, targetTableIdentifier);
return new ObjectExpression(qs, this, te, refMapping, targetTe, selectMapping);
}
}
}