Query doesn't return results in versions 2.9.x when there's a unique property in (where/and .. or ..) clause. It ignores the or operator.
@Entity public class User { .. @Unique private String userName; .. } select u from User u where (u.userName = :userName or :userName is null) // null input for :userName parameter
2.8.9 Query plan description ============================ [Step 1] Scan type User locating all the User (u) instances. [Step 2] Evaluate fields in User (u) instances. [Step 3] Filter the results of step 2 retaining only results that satisfy: or((:userName==null),(u.userName=:userName)). [Step 4] Apply selection and prepare final results. <filterPlan 3.786 0.76/1.18 or((:userName==null),(u.userName=:userName))> <extractPlan 3.7225 0.70/1.18 u(User)> <btreePlan 3.6342 0.70/1.18 u(User) type(User[all]) /> </extractPlan> </filterPlan>
2.9.x Query plan description ============================ [Step 1] Scan index User[userName] locating User (u) instances that satisfy: (u.userName=:userName). [Step 2] Order the results of step 1 by: u. [Step 3] Use NULL as a result (for LEFT OUTER JOIN). [Step 4] Merge the results of steps 2, 3 using OR. [Step 5] Apply selection and prepare final results. <mergePlan or 3.1183 0.72/-0.43 0> <orderPlan 4.9074 0.71/-0.12 u> <btreePlan 3.0043 0.71/-0.12 u(User) index(-101[(u.userName=:userName)]) /> </orderPlan> <onlyNull /> </mergePlan>