From 55f5c9c5bdc667e9bcfcf172f8bcf5f81bb58555 Mon Sep 17 00:00:00 2001 From: Vlad Mihalcea Date: Wed, 12 Dec 2018 15:17:06 +0200 Subject: [PATCH] HHH-13153 - No content in 15.1. Query API of User Guide --- .../userguide/chapters/query/hql/HQL.adoc | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/documentation/src/main/asciidoc/userguide/chapters/query/hql/HQL.adoc b/documentation/src/main/asciidoc/userguide/chapters/query/hql/HQL.adoc index 9f1cf918e7..c6db44508d 100644 --- a/documentation/src/main/asciidoc/userguide/chapters/query/hql/HQL.adoc +++ b/documentation/src/main/asciidoc/userguide/chapters/query/hql/HQL.adoc @@ -11,9 +11,6 @@ A JPQL query is always a valid HQL query, the reverse is not true, however. Both HQL and JPQL are non-type-safe ways to perform query operations. Criteria queries offer a type-safe approach to querying. See <> for more information. -[[query-api]] -=== Query API - [[hql-examples-domain-model]] === Example domain model @@ -44,10 +41,19 @@ include::{modeldir}/WireTransferPayment.java[tags=hql-examples-domain-model-exam ---- ==== -[[jpql-api]] -=== JPA Query API +[[query-api]] +=== Query API -In JPA the query is represented by `javax.persistence.Query` or `javax.persistence.TypedQuery` as obtained from the `EntityManager`. +When using Hibernate, you can execute entity queries either via JPA or the Hibernate-specific API. +Since 5.2, the Hibernate `Session` interface extends the JPA `EntityManager` interface. +For this reason, the query API was also merged, and now the Hibernate `org.hibernate.query.Query` interface extends the JPA `javax.persistence.Query`. + +Next, we are going to see how the query API differs between the standard JPA interfaces and the Hibernate-specific API. + +[[jpql-api]] +==== JPA Query API + +In JPA, the query is represented by `javax.persistence.Query` or `javax.persistence.TypedQuery` as obtained from the `EntityManager`. The create an inline `Query` or `TypedQuery`, you need to use the `EntityManager#createQuery` method. For named queries, the `EntityManager#createNamedQuery` method is needed. @@ -183,7 +189,7 @@ include::{sourcedir}/HQLTest.java[tags=jpql-api-single-result-example] ==== [[hql-api]] -=== Hibernate Query API +==== Hibernate Query API In Hibernate, the HQL query is represented as `org.hibernate.query.Query` which is obtained from a `Session`. If the HQL is a named query, `Session#getNamedQuery` would be used; otherwise `Session#createQuery` is needed.