I've found similar questions, but no answers.
class SomeDomain {
static hasMany= [productData:ProductData]
}
ProductData is simple type/value pair
I'm trying to find all SomeDomains that have multiple products of certain type (in a loop). Currently the relevant portion of the criteria looks like:
SomeDomain.createCriteria.list {
somedata.each { type, value ->
productData {
eq("type", type)
eq("value", value)
}
}
}
However, this generates only a single join with the SQL:
from some_domain this_ inner join product_data productdata_a1_ on this_.id=productdata_a1_.some_domain_id
where (productdata_a1_.type_id=4 and productdata_a1_.value='GC')
and (productdata_a1_.type_id=5 and productdata_a1_.value='P1')
obviously type_id is never going to succeed on and'd checks for =4 and =5...
What I'd really like is two inner joins to product_data... can't figure out how to force this, though.
I tried createAlias("productData", "product-${index}") this gave org.hibernate.QueryException: duplicate association path: productData