Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Help needed on Hibernate Query

 
Selva Varadhan
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have the query like the one which is available in the Hibernate 3.0.5 reference document.

"select new Family(mother, mate, offspr)from DomesticCat as mother
join mother.mate as mateleft join mother.kittens as offspr"

But in my case, i want to pass parameters like character, boolean and strings externaly to the constructor, that is not coming from the database.

ex :
I have the Constrctor like "Family(boolean a, char b,String value)"
for that i did

"select new Family(1,'b', mother )from DomesticCat as mother
join mother.mate as mateleft join mother.kittens as offspr"

but i m getting the exception like there is no proper constructor.

Any one can help on my scenario.

Regards,
Selva varadhan
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One thing I see in your strings is that there is a space missing between the "mate" and "left"

Not that that is probably your issue, but just in case, do you also have a no-args constructor?

Mark
 
Selva Varadhan
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Mark,

I have no argument Constructor also.

Regards,
Selva varadhan.
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What about that missing space?

Is that just a copy and paste error, or is your code the exact same?

Mark
 
Michael Duffy
Ranch Hand
Posts: 163
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Selva Varadhan:
Hi,
I have the query like the one which is available in the Hibernate 3.0.5 reference document.

"select new Family(mother, mate, offspr)from DomesticCat as mother
join mother.mate as mateleft join mother.kittens as offspr"

But in my case, i want to pass parameters like character, boolean and strings externaly to the constructor, that is not coming from the database.

ex :
I have the Constrctor like "Family(boolean a, char b,String value)"
for that i did

"select new Family(1,'b', mother )from DomesticCat as mother
join mother.mate as mateleft join mother.kittens as offspr"

but i m getting the exception like there is no proper constructor.

Any one can help on my scenario.

Regards,
Selva varadhan


Your constructor looks like this:




Yet your code calls this constructor:



I think the compiler is complaining because 1 is not a boolean and mother may not be a string - you want to pass true and "mother" in that case, right? I think the query in Hibernate is not correct.

%
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic