gavin wrote:
Its a bit unclear what you want.
OK, I will try to explain it as clear as I can.
If I execute this:
Code:
from parent p where p.id=:id
The resulting list has
one object of type "parent" which has a Set of
N objects of type "child". N is the number of childs of the given parent.
If I execute this:
Code:
select p.id, elements(p.childs) from parent p where p.id=:id
The resulting list has
N arrays of 2 objects, the first one being the ID and the second one an object of type "child".
What I would want is that the resulting list had just
one array of 2 objects, the first one being the ID and the second one a Set of
N objects of type "child".
Sorry but I can't explain it better.
I would get the whole object using the first query, but the "parent" table is too big and I don't need all its fields.
The last thing I've tried is declaring a constructor like this:
Code:
public parent(Long id, Set childs)
and with a query like this:
Code:
select new parent(p.id, elements(p.childs)) from parent p where p.id=:id
but Hibernate tells me that "parent" class doesn't have the requested constructor.