Skip to content

Commit

Permalink
Reorder documentation of class-based projection support for JPA Nativ…
Browse files Browse the repository at this point in the history
…e Queries.

Closes spring-projects#3599
  • Loading branch information
mp911de committed Aug 29, 2024
1 parent 6ecb45f commit b00220b
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
[[jpa.projections]]
= Projections

include::{commons}@data-commons::page$repositories/projections.adoc[leveloffset=+1]
:projection-collection: Collection

include::{commons}@data-commons::page$repositories/projections-intro.adoc[]

NOTE: It is important to note that <<projections.dtos,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 javadoc:{hibernatejavadocurl}org.hibernate.query.ResultListTransformer[]

include::{commons}@data-commons::page$repositories/projections-interface.adoc[leveloffset=1]

include::{commons}@data-commons::page$repositories/projections-class.adoc[leveloffset=1]


0 comments on commit b00220b

Please sign in to comment.