{
throw new IncompatibleQueryElementTypeException(elementType, candidateClass);
}
ClassLoaderResolver clr = sm.getObjectManager().getClassLoaderResolver();
DatastoreIdentifier listTableAlias = storeMgr.getIdentifierFactory().newIdentifier(
IdentifierFactory.TABLE, listName);
// QueryStatement for the join table
QueryExpression stmt = dba.newQueryStatement(containerTable, listTableAlias, clr);
// Join to the owner
ScalarExpression ownerExpr = ownerMapping.newScalarExpression(stmt, stmt.getTableExpression(listTableAlias));
ScalarExpression ownerVal = ownerMapping.newLiteral(stmt, sm.getObject());
stmt.andCondition(ownerExpr.eq(ownerVal), true);
if (storeMgr.getOMFContext().getTypeManager().isSupportedType(candidateClass))
{
// Non-PC(embedded) - select the join table element
stmt.select(listTableAlias, elementMapping);
}
else
{
// PC
DatastoreClass candidateTable = storeMgr.getDatastoreClass(candidateClass, clr);
// Add the element table to the query, called "LIST_ELEMENTS"
DatastoreIdentifier elementTblAlias = storeMgr.getIdentifierFactory().newIdentifier(
IdentifierFactory.TABLE, "LIST_ELEMENTS");
LogicSetExpression elementTblExpr = stmt.newTableExpression(candidateTable, elementTblAlias);
// Inner Join from the ID of the element to the element mapping of the join table
JavaTypeMapping elementTableID = candidateTable.getIDMapping();