now this may works, but the way i see it, thats a lots of query for one simple task. i know i can get the same result just with a single line of sql string ("delete from category_product where product_id = ?"). but im just curious, is there more sophisticated way to achieve this in grails? (besides executing the sql string)

1 Answer
1

and call delete on Category instead. Why are you using a unidirectional relation in this case? Wouldn't it be better with a bi-directional one? In the case above you iterate over all Categories each time you delete a Product which is a resource heavy operation (depending on you many categories you have of course), the better solution would be to find the Category via a bi-directional relation like this: