JPA: Query that returns multiple entities

Justin Kredible picture Justin Kredible · Jul 29, 2011 · Viewed 74.1k times · Source

I'm writing a JPQL query that joins across three tables. In my resultlist I would like to get all three entities per matching row (hope that makes sense).

Any ideas?

Hibernate 3.x is my JPA provider.

Answer

Tassos Bassoukos picture Tassos Bassoukos · Jul 30, 2011

IIRC, you can do a SELECT o1, o2, o3 FROM EntityA o1, EntityB o2, EntityC o3 WHERE ...., and the result will be a List<Object[3]>, where the array contents will contain the o1,o2,o3 values.