I\'m using JPQL and want to receive some normal parameters and a collection in a Constructor Expression to directly create the DTO-objects. But if the Collection is empty, I
I had a similar problem and tried "Object" in DTO constructor as James suggested, but a child object is passed in and it seems that it is only the first child instead of the expected List/Array of children.
I ended up with a "normal" query creating all the DTOs in a for loop.
TypedQuery query = em.createQuery("SELECT p FROM Parent p", Parent class);
List list = query.getResultList();
List result = new ArrayList<>();
for (Parent p : list)
{
DTO dto = new DTO();
//set dto props and fill collection
result.add(obj);
}
return result;