Quantcast

how to delete all rows in a many side in a on-to-many relationship

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

how to delete all rows in a many side in a on-to-many relationship

chichibek bros
hi group, i need to delete all rows from a many side in an one-to-many relationship

in this escenario is possible to do something like: parentInstane.children.delete() or i need to iterate over each child and then delete each one

thanks
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: how to delete all rows in a many side in a on-to-many relationship

bobbywarner
You can use executeUpdate to delete all the children from many side of one-to-many:

Child.executeUpdate("delete Child c where c.parent = :parent", [parent: p1])


Hope that helps!
Bobby
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: how to delete all rows in a many side in a on-to-many relationship

chichibek bros
Thanks a lot Bobby.

2012/9/21 bobbywarner <[hidden email]>
You can use executeUpdate to delete all the children from many side of
one-to-many:

Child.executeUpdate("delete Child c where c.parent = :parent", [parent: p1])


Hope that helps!
Bobby



--
View this message in context: http://grails.1312388.n4.nabble.com/how-to-delete-all-rows-in-a-many-side-in-a-on-to-many-relationship-tp4635304p4635312.html
Sent from the Grails - user mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email



Loading...