-->
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: HQL question
PostPosted: Tue Apr 24, 2007 5:21 am 
Newbie

Joined: Mon Mar 26, 2007 5:26 am
Posts: 10
Hey all

I have a movies table which in turn has a category property (int) ranging from 0 to 11. I'm trying to select one movie from each category and return the result, but am finding it difficult to do so. Is this possible with a single HQL statement?

Thanks!


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 24, 2007 9:30 am 
Expert
Expert

Joined: Tue Jul 11, 2006 10:21 am
Posts: 457
Location: Columbus, Ohio
Hmm...not quite clear on your question (you want a random movie from each category, or a specific one, or what), but here's one way of getting one movie given a category value.

Code:
session.createQuery("from Movie where category = :catvalue").setInteger("catvalue", 11).setMaxResults(1).uniqueResult();


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.