Exception occurs when using criteria exist queries

Description

Exception occurs when using criteria exist queries

When using a Criteria query with Exist with subquery, a "QueryException" is raised. The exception is handled, quoting the remark:

"//not found in inner query , try the outer query"

The query executes successfully, but causes a significant performance overhead because of the exception.

This can easily be reproduced, for example:

DetachedCriteria dc = DetachedCriteria.For(typeof(Employee))
.SetProjection(Projections.Id())
.Add(Expression.Eq("FirstName", "David"))
.Add(Property.ForName("Department.Id").EqProperty("department.Id"));

IList<Department> departments =
session.CreateCriteria(typeof(Department), "department")
.Add(Subqueries.Exists(dc))
.List<Department>();

Environment

None

Assignee

Unassigned

Reporter

Tomer Avissar

Components

Fix versions

Affects versions

Priority

Minor
Configure