I have tried this solution:
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");
I'm getting this:
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)
So it seems to be returning List
of Object
s instead of Tuple
s. Is Tuple
not supported by EclipseLink or what is the problem?
Debugger shows it's actually a Vector
of Object
s:
I'm using TomEE 8 which uses EclipseLink 2.7.4.v20190115 for JPA. I could try with JPA Criteria Query but I'm converting from SQL and it would be easier to convert it to JPQL.
Edit 1
Here is an answer from writer of the linked article which also suggests this should work.
Edit 2
EclipseLink issue created.
Edit 3
Luckily it works with JPA Criteria Query (CriteriaBuilder#createTupleQuery()
). It's more work to convert SQL to that but at least it works.