I've got a select query that returns a new object. I saw in the documentation, that you can do this:
Code:
select new Family(mother, mate, offspr)
from eg.DomesticCat as mother
join mother.mate as mate
left join mother.kittens as offspr
So long as Family has the approriate constructor. My query is a little different. I'm returning a second object along with the new object, like:
Code:
select new Family(mother, mate, offspr), mother.sex
from eg.DomesticCat as mother
join mother.mate as mate
left join mother.kittens as offspr
I know the example doesn't make much sense since you should already have the mother's sex from the Family object, but you get the idea of what I'm trying to do.
I get the exception:
Code:
Query list exception.; nested exception is:
net.sf.hibernate.PropertyNotFoundException: no appropriate constructor in class: Family
After debugging the net.sf.hibernate.util.ReflectHelper.getConstructor(), I found that it was looking for a constructor with one too many parameters than I expected. It turns out that it was trying to construct Family(mother, mate, offspr, mother.sex).
Is this a bug? Or, do I need some extra parentheses?
I was hoping the query would return an array of type Object[] with the first object being Family and the second being a Character. Does anyone know how I can make this work?
Thanks,
Chrisjan