How can I write a "not exists" query in HQL? I am trying to get an HQL not exists query which returns the same results as this Oracle SQL query:
Your named query is not valid (school_id
is not a property of the Student
entity), which prevents the SessionFactory
from being instantiated. You need to think object and associations, not columns. Try this instead:
from School as s
where not exists (
from Student as st
where st.school = s
and st.status.id not in (0,1,2,3,4)
)