From the course: Java Persistence with JPA and Hibernate

Unlock the full course today

Join today to access over 24,400 courses taught by industry experts.

JPQL queries

JPQL queries

- [Instructor] JPQL or Jakarta Persistence Query Language is kind of an adoption of SQL, because its syntax is quite similar to SQL. JPQL is used to issue queries on a database within an ORM framework. Unlike SQL, where queries are issued directly on the database, in JPQL, queries are issued on the entity model. In other words, queries are issued on the entity instances in the persistence context. This makes it very convenient for Java developers to use, because JPQL queries work with entity instances in the context, but the language, that the database understands, is SQL. So whatever the JPQL queries that the application issues should be transformed to SQL by Hibernate or the ORM framework that's used. So essentially the JPQL queries that you write should be a valid SQL. Also, prior to learning how to write JPQL queries, it's important that you are familiar with the SQL syntaxes. To ensure that we are issuing valid SQL, it's advisable to log SQL statements by setting the…

Contents