-->
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.  [ 6 posts ] 
Author Message
 Post subject: named query: select new xxx(a,b) problem
PostPosted: Wed Sep 24, 2003 11:13 am 
Beginner
Beginner

Joined: Wed Sep 24, 2003 11:06 am
Posts: 21
Location: Denmark
I have a named query that looks like this:

select new PiSimilarity(p.pi,n.similarity)
from Neighbours as n
join n.id.sequenceA as s
join s.proteins as p
where n.id.sequenceB=:sequence
and n.similarity>=:similarity

When running it i get:
net.sf.hibernate.QueryException: could not find constructor for: PiSimilarity: <init>

If i replace "new PiSimilarity(p.pi,n.similarity)" with "p.pi,n.similarity" it works ok...

the ctor for PiSimilarity is "public PiSimilarity(Integer pi, Float similarity)"
and the protein.pi and neighbours.similarity columns are defined as Integer and Float, respectively..

any idea why it doesnt work?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 24, 2003 12:08 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
I would guess that the types don't match from the resultset and the types on the class. I can see you claim that they match but not matching is the only explanation the I can think off.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 24, 2003 12:12 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Ah, it expects primitive types, ie. int, float.

This kinda sucks and should be changed....


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 24, 2003 12:32 pm 
Beginner
Beginner

Joined: Wed Sep 24, 2003 11:06 am
Posts: 21
Location: Denmark
when using the "select p.pi, n.similarity..." variant, i get an Object array back with 2 objects in it, at index 0 a java.lang.Integer and at index 1 a java.lang.Float.. So my types do match....


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 24, 2003 12:36 pm 
Beginner
Beginner

Joined: Wed Sep 24, 2003 11:06 am
Posts: 21
Location: Denmark
i got inspired from the hibernate reference doc, which has the following example:

select new Family(mother, mate, offspr)
from eg.DomesticCat as mother
join mother.mate as mate
left join mother.kittens as offspr

but mother, mate and offspr are not primitive types.. theyre real classes (and even persistent ones too :o).. or is this example just wrong???


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 24, 2003 1:03 pm 
Beginner
Beginner

Joined: Wed Sep 24, 2003 11:06 am
Posts: 21
Location: Denmark
gavin wrote:
Ah, it expects primitive types, ie. int, float.

This kinda sucks and should be changed....


I just changed the ctor to "PiSimilarity(int pi, float similarity) and it seems to be working.. but i think you're right, the ctor arguments should match the types of the attributes used when calling the ctor...


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

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.