If I have an entity 'Person' that has an associated collection 'Books' why can't I write a query like this:
Code:
ThisQueryBean thisQueryBean = entityManager.createQuery(
"select new ThisQueryBean(p, p.books) from Person as p")
.getResultList();
The problem seems to be with p.books being a collection. If it is an object or primitive then it is fine. The constructor for ThisQueryBean looks like this:
Code:
public ThisQueryBean(Person p, List<Book> books) {
etc, etc
Is what I am trying to do not supported/stupid? It would be very convenient. The alternative is to do a distinct join which works but doesn't feel as elegant.
Thanks,
Damian