Search code examples
javahibernatejpajpql

JPA: Query that returns multiple entities


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.


Solution

  • 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.