From fea2a1a515f5bd9f87604ac80abc0d7b76054633 Mon Sep 17 00:00:00 2001 From: "Greg L. Turnquist" Date: Thu, 29 Sep 2022 11:51:56 -0500 Subject: [PATCH] Update class-based DTO notes in reference docs. Closes #2558. Related: #2635. --- src/main/asciidoc/repository-projections-dto-limitations.adoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/asciidoc/repository-projections-dto-limitations.adoc b/src/main/asciidoc/repository-projections-dto-limitations.adoc index 44ab3a6bb..bc2a33df1 100644 --- a/src/main/asciidoc/repository-projections-dto-limitations.adoc +++ b/src/main/asciidoc/repository-projections-dto-limitations.adoc @@ -1 +1 @@ -NOTE: Class based projections do not work with native queries. As a workaround you may use named queries with `ResultSetMapping` or the Hibernate specific https://docs.jboss.org/hibernate/orm/6.0/javadocs/org/hibernate/transform/ResultTransformer.html[`ResultTransformer`] +NOTE: Class-based projections with JPQL is limited to *constructor expressions* in your JPQL expression, e.g. `SELECT new com.example.NamesOnly(u.firstname, u.lastname) from User u`. (Note the usage of a FQDN for the DTO type!) This JPQL expression can be used in `@Query` annotations as well where you define any named queries. And it's important to point out that class-based projections do not work with native queries AT ALL. As a workaround you may use named queries with `ResultSetMapping` or the Hibernate specific https://docs.jboss.org/hibernate/orm/6.0/javadocs/org/hibernate/transform/ResultTransformer.html[`ResultTransformer`]