var.setVariableType(qs.getClassLoaderResolver().classForName(mapStore.getValueType()));
}
String vtIdentifier = "UNBOUND" + '.' + var.getVariableName();
String mtIdentifier = idFactory.newIdentifier(idFactory.newIdentifier(te.getAlias(), fieldName), var.getVariableName()).getIdentifier();
DatastoreIdentifier mtRangeVar = idFactory.newIdentifier(IdentifierFactory.TABLE, mtIdentifier);
DatastoreIdentifier vtRangeVar = idFactory.newIdentifier(IdentifierFactory.TABLE, vtIdentifier);
QueryExpression qexpr = getBackingStoreQueryable().getExistsSubquery(qs, mapping, te, mtRangeVar);
var.bindTo(getBackingStoreQueryable().joinValuesTo(qexpr,
qs,
mapping,
te,
mtRangeVar,
var.getVariableType(),
expr,
vtRangeVar));
return new ExistsExpression(qs, qexpr, true);
}
else if (expr instanceof Literal)
{
String mtIdentifier = idFactory.newIdentifier(te.getAlias(), fieldName).getIdentifier();
DatastoreIdentifier mtRangeVar = idFactory.newIdentifier(IdentifierFactory.TABLE, mtIdentifier);
DatastoreIdentifier vtRangeVar;
int n = 0;
do
{
String vtIdentifier = mtIdentifier + '.' + (++n);
vtRangeVar = idFactory.newIdentifier(IdentifierFactory.TABLE, vtIdentifier);
} while (qs.getTableExpression(vtRangeVar) != null);
ClassLoaderResolver clr = qs.getClassLoaderResolver();
QueryExpression qexpr = getBackingStoreQueryable().getExistsSubquery(qs, mapping, te, mtRangeVar);
ScalarExpression joinValuesExpr = getBackingStoreQueryable().joinValuesTo(qexpr,
qs,
mapping,
te,
mtRangeVar,
clr.classForName(expr.getMapping().getType()),
expr,
vtRangeVar);
qexpr.andCondition(expr.eq(joinValuesExpr));
return new ExistsExpression(qs, qexpr, true);
}
else
{
String mtIdentifier = idFactory.newIdentifier(te.getAlias(), fieldName).getIdentifier();
DatastoreIdentifier mtRangeVar = idFactory.newIdentifier(IdentifierFactory.TABLE, mtIdentifier);
DatastoreIdentifier vtRangeVar;
if (expr.te == null) // literals
{
int n = 0;