-->
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.  [ 1 post ] 
Author Message
 Post subject: HQL distinct on a collection property
PostPosted: Wed Oct 26, 2005 12:39 pm 
Newbie

Joined: Wed Jun 22, 2005 6:38 pm
Posts: 7
Hibernate version: 3

Name and version of the database you are using: Oracle 10g

I have a class Cat with a collection of Kitten objects. I'm trying to perform a select on Cat with a distinct on Cat.kittens.id. The idea is that my HQL will return only the first Cat object that contains a specific kitten.

For instance:

Table: CAT
id | name
_________
0 kenny
1 stan
2 kyle

Table: KITTEN
id | name
____________
0 grumpy
1 sleepy
2 dopey


Table: CAT_KITTEN_XREF
cat_id | kitten_id
_____________________
0 0
0 1
1 1

I would see Cats 0 and 2 returned. Cat 1 would not be returned because it contained a matching kitten with Cat 0 (Kitten 1).

Does anyone know if this can be done via HQL?


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

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.