-->
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: selecting a collection property using criteria queries
PostPosted: Tue Sep 06, 2005 4:56 pm 
Beginner
Beginner

Joined: Fri Oct 15, 2004 9:58 pm
Posts: 25
Hibernate version:3.0.5

If I want to select a collection property (cat.kittens) the following HQL query suffices.
Code:
select elements(cat.kittens) from eg.Cat cat

But how to do this using Critieria Queries?
I tried the following and it doesn't work
Code:
session.createCriteria(eg.Cat.class,"cat").createCriteria("cat.kittens", "kit")
      .setProjection(
              Projections.projectionList().add(Projections.property(cat.kittens))).list;

The resulting SQL is
Code:
select this_.id from CAT as this_ inner join CAT as kit_ on this_id = kit_.mother
which is seems to be wrong.
Is there any other way to write a criteria query to do this? Using 3.1beta helps?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 06, 2005 10:39 pm 
Beginner
Beginner

Joined: Fri Oct 15, 2004 9:58 pm
Posts: 25
There seems to be a JIRA issue that is some what similar to this
http://opensource2.atlassian.com/projec ... se/HHH-869.

The JIRA issue seems to ask for querying against the contents of the collection and what I want is the ability to select all contents of the collection as projected elements. Do I need to file another issue for this or is there any other way to do this.

Thanks,
Prasad


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 06, 2005 10:46 pm 
Beginner
Beginner

Joined: Fri Oct 15, 2004 9:58 pm
Posts: 25
There was an extra . at the end in the previous post
http://opensource2.atlassian.com/projec ... se/HHH-869


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.