-->
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: Criteria:comparing list of associations
PostPosted: Thu Aug 12, 2004 11:32 am 
Beginner
Beginner

Joined: Wed Jul 14, 2004 11:51 am
Posts: 43
Hello,

I am using the Criteria and Criterion framework to build a simple query. To explain my problem, here is an example:

ProductGroup has a many to many association to Product. I want to build myself a query that will look if two ProductGroup are identical. Therefore, I need to know if the list of products of both are the same. What I am doing right now is this:
Code:
        Collection products = productGroup.getProducts();
        Criteria productCriteria = productGroupCriteria.createCriteria("products");
        Iterator i = products.iterator();
        while(i.hasNext()) {
            Product product = (Product) i.next();
            Criterion d = Expression.eq("id", product.getId());
            productGroupCriteria.add(d);
        }


This does not work if I have a persisted instance that has the same products as the productGroup I am iterating and some more. In other words my criteria tests if the list of my current productGroup is IN the persisted instances.

How can I test if they are equal? and not if one contains another?

I have also tried:
Code:

        Criterion d = Expression.eq("days", route.getDays());


but this obviously doesn't work since days is not a property but a list.

Any help would be greatly appreciated



Hibernate version:2.1


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.