else
{
etRangeVar = expr.te.getAlias();
}
ClassLoaderResolver clr=qs.getClassLoaderResolver();
QueryExpression qexpr = getBackingStoreQueryable().getExistsSubquery(qs, mapping, te, ctRangeVar);
ScalarExpression expr1 = getBackingStoreQueryable().joinElementsTo(qexpr,
qs,
mapping,
te,
ctRangeVar,
clr.classForName(expr.getMapping().getType()),
expr,
expr.te == null ? etRangeVar : expr.te.getAlias());
qexpr.andCondition(expr.eq(expr1));
return new ExistsExpression(qs, qexpr, true);
}
else
{
String ctIdentifier = idFactory.newIdentifier(te.getAlias(), fieldName).getIdentifier();
DatastoreIdentifier ctRangeVar = qs.getStoreManager().getIdentifierFactory().newIdentifier(IdentifierFactory.TABLE, ctIdentifier);
DatastoreIdentifier etRangeVar;
if (expr.te == null) // literals
{
int n = 0;
do
{
String etIdentifier = ctIdentifier + '.' + (++n);
etRangeVar = qs.getStoreManager().getIdentifierFactory().newIdentifier(IdentifierFactory.TABLE, etIdentifier);
} while (qs.getTableExpression(etRangeVar) != null);
}
else
{
etRangeVar = expr.te.getAlias();
}
ClassLoaderResolver clr = qs.getClassLoaderResolver();
ScalarExpression joinExpr =
getBackingStoreQueryable().joinElementsTo(expr.getQueryExpression(),
qs,
mapping,
te,
ctRangeVar,
clr.classForName(arrayStore.getElementType()),
expr,
etRangeVar);
return joinExpr.eq(expr);
}