-->
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: mutiple aliases for same collection in a Criteria
PostPosted: Thu Aug 19, 2004 2:37 pm 
Newbie

Joined: Thu Aug 19, 2004 2:13 pm
Posts: 1
In a many-to many relationship between Cat and Dog entities I am given a collection of dogs, and need to find a collection of cats
where each cat is related to all given dogs.

One way of doing it is to join a Cat entity with Dog entity dogs.size() times, but I can't get it to work with Criteria.createAlias() or createCriteria() and I really would like to use Criteria API since my query is pretty dynamic and has many more optional criterias.

In other words, I need something similar to this, that works:

given a Long[] dogid; with 2 IDs in it:

Code:
...
Criteria crit = session.createCriteria(Cat.class)
       crit = crit.createAlias("dogs", "dog1")
                     .createAlias("dogs", "dog2")
                     .add(Expression.eq("dog1.id", dogid[0]))
                     .add(Expression.eq("dog2.id", dogid[1]));

   crit.list();
...       

crashes with an error: table "dog1" is not found.
Hibernate does not allow to have 2 aliases for same collection of docs :(

Any help is greatly appreciated.

Hibernate version: 2.1.2


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.