Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Got IndexOutOfBoundsException when projecting data on maps list [DATAJPA-1562] #1872

Closed
spring-projects-issues opened this issue Jun 20, 2019 · 4 comments
Assignees
Labels
in: core type: bug

Comments

@spring-projects-issues
Copy link

@spring-projects-issues spring-projects-issues commented Jun 20, 2019

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:

@Repository
interface UserRepo extends CrudRepository<User, Integer> {

    @Query("SELECT id as id, phone as phone FROM User")
    List<Map<String, String>> fetchPhones();
}

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

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Jun 20, 2019

Jens Schauder commented

The issue does NOT affect the current master, i.e. 2.2 snapshot

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Jun 21, 2019

Jens Schauder commented

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.

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Jun 21, 2019

Jens Schauder commented

One of the issues that changed the algorithm for identifying the target type.

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Jun 21, 2019

Jens Schauder commented

This introduced the insufficient version check

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core type: bug
Projects
None yet
Development

No branches or pull requests

2 participants