Projecting on maps list causes java.lang.IndexOutOfBoundsException: Index: 1, Size: 1
For example, use fetchPhones method of this repository:
@RepositoryinterfaceUserRepoextendsCrudRepository<User, Integer> {
@Query("SELECT id as id, phone as phone FROM User")
List<Map<String, String>> fetchPhones();
}
The source of the problem is that we expect a Tuple as the return type in order to convert it to a Map.
But before actually requestion a Tuple we check if the Hibernate Versions actually supports Tupel as a query target.
That check simply checks for the version being greater than 5.2.11 which of course fails for all Hibernate 3 and 4 versions which at least to some extend very well support Tupel.
vladimir-golovnin opened DATAJPA-1562 and commented
Projecting on maps list causes java.lang.IndexOutOfBoundsException: Index: 1, Size: 1
For example, use fetchPhones method of this repository:
This case appeared in 1.11.11 version of Spring Data JPA. It works as expected in version 1.11.10.
Sample project: https://github.com/vladimir-golovnin/spring-data-jpa-map-list-issue
Affects: 1.11.22 (Ingalls SR22)
Issue Links:
DATAJPA-1209 Compatibility with Hibernate < 5.2.11 broken for projections on native queries
DATAJPA-1273 Named query execution doesn't use Tuple execution for projections
Referenced from: pull request #387
The text was updated successfully, but these errors were encountered: