diff --git a/pom.xml b/pom.xml index 17776328bc..c4170b37f3 100755 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ <groupId>org.springframework.data</groupId> <artifactId>spring-data-jpa-parent</artifactId> - <version>3.3.0-SNAPSHOT</version> + <version>3.3.x-3286-SNAPSHOT</version> <packaging>pom</packaging> <name>Spring Data JPA Parent</name> diff --git a/spring-data-envers/pom.xml b/spring-data-envers/pom.xml index 470678d048..813a47a58b 100755 --- a/spring-data-envers/pom.xml +++ b/spring-data-envers/pom.xml @@ -5,12 +5,12 @@ <groupId>org.springframework.data</groupId> <artifactId>spring-data-envers</artifactId> - <version>3.3.0-SNAPSHOT</version> + <version>3.3.x-3286-SNAPSHOT</version> <parent> <groupId>org.springframework.data</groupId> <artifactId>spring-data-jpa-parent</artifactId> - <version>3.3.0-SNAPSHOT</version> + <version>3.3.x-3286-SNAPSHOT</version> <relativePath>../pom.xml</relativePath> </parent> diff --git a/spring-data-jpa-distribution/pom.xml b/spring-data-jpa-distribution/pom.xml index 6bd074181c..3fa0255518 100644 --- a/spring-data-jpa-distribution/pom.xml +++ b/spring-data-jpa-distribution/pom.xml @@ -14,7 +14,7 @@ <parent> <groupId>org.springframework.data</groupId> <artifactId>spring-data-jpa-parent</artifactId> - <version>3.3.0-SNAPSHOT</version> + <version>3.3.x-3286-SNAPSHOT</version> <relativePath>../pom.xml</relativePath> </parent> diff --git a/spring-data-jpa/pom.xml b/spring-data-jpa/pom.xml index 67ad4cabb2..d99c3f05bc 100644 --- a/spring-data-jpa/pom.xml +++ b/spring-data-jpa/pom.xml @@ -6,7 +6,7 @@ <groupId>org.springframework.data</groupId> <artifactId>spring-data-jpa</artifactId> - <version>3.3.0-SNAPSHOT</version> + <version>3.3.x-3286-SNAPSHOT</version> <name>Spring Data JPA</name> <description>Spring Data module for JPA repositories.</description> @@ -15,7 +15,7 @@ <parent> <groupId>org.springframework.data</groupId> <artifactId>spring-data-jpa-parent</artifactId> - <version>3.3.0-SNAPSHOT</version> + <version>3.3.x-3286-SNAPSHOT</version> <relativePath>../pom.xml</relativePath> </parent> diff --git a/src/main/antora/modules/ROOT/pages/repositories/projections.adoc b/src/main/antora/modules/ROOT/pages/repositories/projections.adoc index 5635695699..00dede4513 100644 --- a/src/main/antora/modules/ROOT/pages/repositories/projections.adoc +++ b/src/main/antora/modules/ROOT/pages/repositories/projections.adoc @@ -4,3 +4,28 @@ include::{commons}@data-commons::page$repositories/projections.adoc[leveloffset=+1] 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 https://docs.jboss.org/hibernate/orm/6.0/javadocs/org/hibernate/transform/ResultTransformer.html[`ResultTransformer`] + +[NOTE] +==== +Some JPA providers may require additional hints when working with <<projections.dtos,Class-based projections>> especially when using those directly with method derived queries. +If you are facing errors like `JpaSystemException: Specified result type did not match Query selection type` make sure to provide a constructor hint via `@PersistenceCreator` to be passed on, as outlined below: + +[source,java] +---- +public class NamesOnly { + + private final String firstname; + private final String lastname; + + protected NamesOnly() { } + + @PersistenceCreator + public NamesOnly(String firstname, String lastname) { + this.firstname = firstname; + this.lastname = lastname; + } + + // ... +} +---- +====