leftCentreExpr = joinTbl.getOwnerMapping().newScalarExpression(qs, joinTblExpr);
rightCentreExpr = joinTbl.getElementMapping().newScalarExpression(qs, joinTblExpr);
}
else if (leftMmd.hasMap())
{
MapTable joinTbl = (MapTable)storeMgr.getDatastoreContainerObject(leftMmd);
DatastoreIdentifier joinTblAlias = storeMgr.getIdentifierFactory().newIdentifier(
IdentifierFactory.TABLE, leftAlias + "." + rightAlias);
joinTblExpr = qs.newTableExpression(joinTbl, joinTblAlias);
leftCentreExpr = joinTbl.getOwnerMapping().newScalarExpression(qs, joinTblExpr);
rightCentreExpr = joinTbl.getValueMapping().newScalarExpression(qs, joinTblExpr);
}
if (i == 1)
{
// And condition to outer candidate
qs.andCondition(leftExpr.eq(leftCentreExpr), true);
}
else
{
// Inner join to table
qs.innerJoin(leftCentreExpr, leftExpr, leftTblExpr, true, true);
}
qs.innerJoin(rightExpr, rightCentreExpr, joinTblExpr, true, true);
}
else if ((relationType == Relation.ONE_TO_MANY_BI &&
(leftMmd.getJoinMetaData() != null || rightMmd.getJoinMetaData() != null)) ||
(relationType == Relation.MANY_TO_ONE_BI &&
(leftMmd.getJoinMetaData() != null || rightMmd.getJoinMetaData() != null)) ||
relationType == Relation.MANY_TO_MANY_BI)
{
// 1-N/N-1 bi JoinTable
ScalarExpression leftExpr = leftTable.getIDMapping().newScalarExpression(qs, leftTblExpr);
ScalarExpression rightExpr = rightTable.getIDMapping().newScalarExpression(qs, rightTblExpr);
ScalarExpression leftCentreExpr = null;
ScalarExpression rightCentreExpr = null;
LogicSetExpression joinTblExpr = null;
if (leftMmd.hasCollection() || rightMmd.hasCollection())
{
CollectionTable joinTbl = (CollectionTable)storeMgr.getDatastoreContainerObject(leftMmd);
DatastoreIdentifier joinTblAlias = storeMgr.getIdentifierFactory().newIdentifier(
IdentifierFactory.TABLE, leftAlias + "." + rightAlias);
joinTblExpr = qs.newTableExpression(joinTbl, joinTblAlias);
leftCentreExpr = joinTbl.getOwnerMapping().newScalarExpression(qs, joinTblExpr);
rightCentreExpr = joinTbl.getElementMapping().newScalarExpression(qs, joinTblExpr);
}
else if (leftMmd.hasMap() || rightMmd.hasMap())
{
MapTable joinTbl = (MapTable)storeMgr.getDatastoreContainerObject(leftMmd);
DatastoreIdentifier joinTblAlias = storeMgr.getIdentifierFactory().newIdentifier(
IdentifierFactory.TABLE, leftAlias + "." + rightAlias);
joinTblExpr = qs.newTableExpression(joinTbl, joinTblAlias);
leftCentreExpr = joinTbl.getOwnerMapping().newScalarExpression(qs, joinTblExpr);
rightCentreExpr = joinTbl.getValueMapping().newScalarExpression(qs, joinTblExpr);
}
if (i == 1)
{
// And condition to outer candidate