I. Definition of JPQL
In Java EE, JPQL (Java Persistence Query Language) is designed specifically for Java applications to access and navigate entity instances. JPQL is an extension of the query language EJB QL used by EJB2, which inherits the EJB QL and makes some changes to it.
Second, JPQL and SQL
PQL is an object-oriented query language, so it can fully understand the characteristics of inheritance, polymorphism, and correlation. And JPQL has built-in a lot of functions, greatly facilitates the function of JPQL query. Of course JPQL is still SQL-based, but the JPQL-to-SQL conversion does not need to be a developer's concern, and the JPQL parser is responsible for completing this transformation, and is responsible for executing the SQL statement to update the database.
SQL is a query language for relational databases, so the objects for SQL operations are data tables, data columns, and objects that JQPL manipulate are entity objects, object properties.
Code comparison
Sql:
Native SQL statement Select name,age,user_id from T_user
JPQL:
Analysis:
The first statement is used to execute a query against the T_user table tables, querying the name, age, and user_id three data columns;
The second statement is used to execute a query against the user entity, querying the name, age, and UserId properties of the user entity.
Third, HQL
HQL (Hibernate query Language) is an object-oriented query, followed by a "table name", where the condition is followed by "fields in the table." When you use queries in Hibernate,
Generally use HQL query statements. Because HQL is object-oriented, and the names and properties of object classes are case-sensitive, they are case-sensitive
Conditional query, SQL, JPQL, hql comparison