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)
)
References
- Hibernate Core Reference Guide
- 14.13. Subqueries