stmt = dba.newQueryStatement(sourceTable, candidateId, clr);
IdentifierFactory idFactory = stmt.getStoreManager().getIdentifierFactory();
// Add join from the join table to the root element table
DatastoreIdentifier targetTableIdentifier = null;
DatastoreIdentifier rootElementTblId = idFactory.newIdentifier(IdentifierType.TABLE, "ELEMENT");
LogicSetExpression rootElementTblExpr = stmt.newTableExpression(candidateTable, rootElementTblId);
ScalarExpression sourceExpr = sourceMapping.newScalarExpression(stmt, stmt.getMainTableExpression());
ScalarExpression rootElementExpr =
candidateTable.getIDMapping().newScalarExpression(stmt, rootElementTblExpr);
if (allowNull)