-->
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: Query a list based on the index field
PostPosted: Sun May 02, 2004 1:57 pm 
Beginner
Beginner

Joined: Tue Sep 09, 2003 9:11 pm
Posts: 32
I believe what I want to do is not possible, I just wanted to confirm...

I have a parent child relationship (Test/Question) using a List. As the user takes the test online I display each question on it's own screen. When a question is answered, I query for the Test and get the next Question using List.get(index).

I was trying to figure out if it is possible to load a question directly without having to load the Test and all Questions first. However, without using native SQL I can not see a way to include the list index field in an HQL query?

I'm a right or did I miss something.

Thanks in advance,
Chris....


Top
 Profile  
 
 Post subject:
PostPosted: Sun May 02, 2004 2:58 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
HQL also provides the built-in index() function, for elements of a one-to-many association or collection of values.
Code:
select item, index(item) from Order order
    join order.items item
where index(item) < 5


Top
 Profile  
 
 Post subject:
PostPosted: Sun May 02, 2004 3:45 pm 
Beginner
Beginner

Joined: Tue Sep 09, 2003 9:11 pm
Posts: 32
Michael -

Thanks! That's exactly what I was looking for in Hibernate.

<feeling like an idiot>
I usually am able to find things like this when I read the documentation or forums....

Just overlooked it...
</>

Chris....


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.