* {@inheritDoc}
*/
public void visit(ExistsExpression expression) {
// First create the subquery
ReportQuery subquery = buildSubquery((SimpleSelectStatement) expression.getExpression());
// Replace the SELECT clause of the exists subquery by SELECT 1 to avoid problems with
// databases not supporting multiple columns in the subquery SELECT clause in SQL. The
// original select clause expressions might include relationship navigations which should
// result in FK joins in the generated SQL, e.g. ... EXISTS (SELECT o.customer FROM Order
// o ...). Add the select clause expressions as non fetch join attributes to the ReportQuery
// representing the subquery. This make sure the FK joins get generated
for (ReportItem item : subquery.getItems()) {
Expression expr = item.getAttributeExpression();
subquery.addNonFetchJoinedAttribute(expr);
}
subquery.clearItems();
Expression one = new ConstantExpression(1, new ExpressionBuilder());
subquery.addItem("one", one);
subquery.dontUseDistinct();
// Now create the EXISTS expression
queryExpression = queryContext.getBaseExpression();
if (expression.hasNot()) {