HQL Query to check if size of collection is 0 or empty

Using IS EMPTY should work (I would favor a JPQL syntax):

SELECT u FROM User u WHERE u.status = 1 AND u.appointments IS EMPTY

If it doesn’t, please show the generated SQL.

References

  • Hibernate Core Reference Guide
    • 14.10. Expressions
  • JPA 1.0 specification
    • Section 4.6.11 “Empty Collection Comparison Expressions”

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)