eclipse-ee4j / eclipse-ee4j/eclipselink
getResultList() not returning Tuple
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 246
- Forks
- 202
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 14
Description
List<javax.persistence.Tuple> result = entityManager.createQuery("select f.Id as Id, f.Project as Project from FirewallRequest f", javax.persistence.Tuple.class)
.getResultList();
result.get(0).get("Project");
causes
java.lang.ClassCastException: class [Ljava.lang.Object; cannot be cast to class javax.persistence.Tuple ([Ljava.lang.Object; is in module java.base of loader 'bootstrap'; javax.persistence.Tuple is in unnamed module of loader java.net.URLClassLoader @7a9273a8)
Tested with 2.7.4 and 2.7.6. I have seen a lot of examples showing this should return key/value pairs in Tuple class, for example here: https://stackoverflow.com/a/59840498/1827453
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the EntityManager.createQuery(..., Tuple.class) and getResultList() call shown in the reproducer, then verify the returned element type for the aliased Id and Project selections. Done means the query returns javax.persistence.Tuple instances so result.get(0).get("Project") works without a ClassCastException.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100