-->
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.  [ 3 posts ] 
Author Message
 Post subject: Howto do a range query in HQL (e,g, between (x, y))
PostPosted: Thu Jun 16, 2005 6:16 pm 
Newbie

Joined: Tue Jan 04, 2005 4:52 pm
Posts: 13
Hibernate version:
2.1.8

Hello,

I can't seem to find a break down of the hql grammer for hibernate2. I have a entity representing a street range as:

Code:
class StreetRange {
  int start;
  int end;
  String name;
}


Given the street name and number I want the StreetRange instance that contains it.

I'd like to do a query like 'from Segment s where s.name = :name and :number between (s.start, s.end)'

I have legacy SQL doing this exact thing but I can't figure out the HQL equivilent.

Any help is much appreciated,

Kastor


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 17, 2005 3:58 am 
Expert
Expert

Joined: Sat Oct 25, 2003 8:49 am
Posts: 490
Location: Vrhnika, Slovenia
What about:
from Segment s where s.name = :name and :number between s.start and s.end


Top
 Profile  
 
 Post subject: This is the answer
PostPosted: Fri Jun 17, 2005 11:57 am 
Newbie

Joined: Tue Jan 04, 2005 4:52 pm
Posts: 13
Thanks Alesj,

This works for me.

Kastor


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.