matcauthon
matcauthon

Reputation: 2261

Transactions in Grails

In several domain class I have a property createdBy with class User. If I delete a user I want to alter all domain objects to use a default user for this property.

I want to do this by transactions (alter all or do nothing). How do I do this with grails transactions?

Upvotes: 0

Views: 140

Answers (1)

Marco
Marco

Reputation: 15929

As -marko- already commented you could do this by implementing a service. Another approach could be to use the 'beforeDelete' event. When using the beforeDelete make sure you use another hibernate Session.

User.withNewSession { 
     // your code here 
} 

Upvotes: 1

Related Questions