-->
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.  [ 2 posts ] 
Author Message
 Post subject: Need help with a query
PostPosted: Tue Apr 17, 2007 3:23 pm 
Newbie

Joined: Tue Apr 17, 2007 1:47 pm
Posts: 2
I have the following tables.

Site
SiteID (PK)
...
LevelID

LevelPriceRangeList
LevelID (PK)
PriceRangeID (PK)

PriceRange
PriceRangeID (PK)
Start
End
...

I have EJB entities for the Site table and the PriceRange table. In the Site table I have a JoinTable relationships that gives me a Set<PriceRange>.

It all works great, except I want a query that will give me a PriceRange with a given siteId and an amount between Start and End. The problem is I can't figure out how to do it with the EJB QL because of the Set.

Thanks,
Eric

_________________
Eric


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 17, 2007 4:10 pm 
Newbie

Joined: Tue Apr 17, 2007 1:47 pm
Posts: 2
I figured it out with this query.

String QUERY = "Select pr from Site as s, PriceRange as pr where pr in elements(s.ranges) and s.siteId=:siteId and " + cost.toString() + "between pr.start and pr.end";

return (PriceRange) pbPM.getEntityManager().createQuery(QUERY).setParameter("siteId", Integer.valueOf(siteId.trim())).getSingleResult();

_________________
Eric


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