-->
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: How to reference a collection of elements using Criteria API
PostPosted: Sat Sep 16, 2006 2:36 pm 
Newbie

Joined: Wed Oct 05, 2005 3:36 am
Posts: 15
Hibernate version: 3.1.1

Hi,

I have been struggling with the following issue for some time, I am hoping that someone can point me in the right direction:


I have an entity (A) which has a one-to-many collection of elements.
To make the problem simple lets say that the collection is just a Set of Strings.
What I want to do is return all A's where the collection contains a particular string, in HQL it is easy to do:

FROM A a WHERE :x in elements(a.bs)


However this is part of a larger query so I am trying to use the Criteria API to build it.
The problem I am having is that I have not been able to find any way to express this query using the Criteria API, specifically:

- The "in" restriction assumes that I will be passing in the RHS of the expression (and I want the left).
- I can't create a DetachedCriteria for the collection, because I have no entity class to use to create it.
- I can create an alias / sub criteria because the collection is of values not entities.
- I can't use the . (dot) notation because the element (string) has no properties I can reference.


Therefore I would greatly appreciate it if someone could point me in the right direction.

TIA


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.