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