From 569a4e08caab390cf0c6d53b7effb87242df2bfa Mon Sep 17 00:00:00 2001 From: Vlad Mihalcea Date: Tue, 3 Jul 2018 14:50:01 +0300 Subject: [PATCH] HHH-12716 - Sample code is required for documentation of disabling polymorphism in queries --- .../asciidoc/userguide/chapters/query/hql/HQL.adoc | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 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 1b3a9ae1f6..7bdeac8349 100644 --- a/documentation/src/main/asciidoc/userguide/chapters/query/hql/HQL.adoc +++ b/documentation/src/main/asciidoc/userguide/chapters/query/hql/HQL.adoc @@ -968,14 +968,20 @@ include::{sourcedir}/HQLTest.java[tags=hql-polymorphism-example, indent=0] This query names the `Payment` entity explicitly. However, all subclasses of `Payment` are also available to the query. -So if the `CreditCardPayment` and `WireTransferPayment` entities extend the `Payment` class, all three types would be available to the entity query, +So, if the `CreditCardPayment` and `WireTransferPayment` entities extend the `Payment` class, all three types would be available to the entity query, and the query would return instances of all three. + +This behavior can be altered in two ways: + +- by limiting the query to select only from the subclass entity +- by using either the `org.hibernate.annotations.Polymorphism` annotation (global, and Hibernate-specific). See the <>. + [NOTE] ==== -This can be altered by using either the `org.hibernate.annotations.Polymorphism` annotation (global, and Hibernate-specific) or limiting them using in the query itself using an entity type expression. +The HQL query `from java.lang.Object` is totally valid (although not very practical from a performance perspetive)! -The HQL query `from java.lang.Object` is totally valid! It returns every object of every type defined in your application. +It returns every object of every entity type defined by your application mappings. ==== [[hql-expressions]]