-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: select returns new Object
PostPosted: Wed Jun 23, 2004 7:26 pm 
Beginner
Beginner

Joined: Wed Mar 17, 2004 4:13 pm
Posts: 21
Location: San Diego, CA
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.