{
if (mapType == MapType.MAP_TYPE_VALUE_IN_KEY)
{
// Select of key in key table (allow union of possible key types)
iteratorMappingDef = new StatementClassMapping();
UnionStatementGenerator stmtGen = new UnionStatementGenerator(storeMgr, clr, keyCls, true, null, null);
stmtGen.setOption(StatementGenerator.OPTION_SELECT_NUCLEUS_TYPE);
iteratorMappingDef.setNucleusTypeColumnName(UnionStatementGenerator.NUC_TYPE_COLUMN);
sqlStmt = stmtGen.getStatement();
containerSqlTbl = sqlStmt.getPrimaryTable();
SQLStatementHelper.selectFetchPlanOfSourceClassInStatement(sqlStmt, iteratorMappingDef,
ownerSM.getExecutionContext().getFetchPlan(), sqlStmt.getPrimaryTable(), emd, 0);
}
else
{
// MAP_TYPE_KEY_IN_VALUE, MAP_TYPE_JOIN
if (emd != null)
{
// Select of key table, joining to join table
iteratorMappingDef = new StatementClassMapping();
UnionStatementGenerator stmtGen = new UnionStatementGenerator(storeMgr, clr, keyCls, true, null, null);
stmtGen.setOption(StatementGenerator.OPTION_SELECT_NUCLEUS_TYPE);
iteratorMappingDef.setNucleusTypeColumnName(UnionStatementGenerator.NUC_TYPE_COLUMN);
sqlStmt = stmtGen.getStatement();
JavaTypeMapping keyIdMapping = sqlStmt.getPrimaryTable().getTable().getIdMapping();
containerSqlTbl = sqlStmt.innerJoin(sqlStmt.getPrimaryTable(), keyIdMapping,
containerTable, null, elementMapping, null, null);