Skip to main content

HQL, JPQL, Native SQL and Parameterized Queries

Learn HQL, JPQL, Native SQL and Parameterized Queries (Phase 5 · Hibernate Querying (Core), Hibernate) with worked examples, diagrams and interview questions. Free on JavaSchoolLab.

JPQL and HQL • JPQL (Jakarta Persistence Query Language) is the standard object-oriented query language: you query entities and their fields , not tables and columns. HQL is Hibernate's superset (more functions, from Course without select , extra joins). In Hibernate 6 both are processed by the same engine (SQM). • Create with em.createQuery(jpql, ResultType.class) (typed): getResultList() , getSingleResult() (throws if none/many), getResultStream() , executeUpdate() for bulk update/delete. • Entity names are case-sensitive, keywords are not. Navigate associations with dot notation (...

More lessons in Phase 5 · Hibernate Querying (Core)