Say we have two GORM-classes
class Team {
static hasMany = [users: User]
User createdBy // User who created this Team
}
class User {
static belongsTo = [team: Team]
}
Grails mistakenly associates the createBy-User with the Team. If I delete the team Grails cascades the delete to the createdBy-User, which is not intended!
How can I prevent that?
class Team {
static hasMany = [users: User]
User createdBy // User who created this Team
static mapping = {
createdBy(cascade: 'none') //only save and update cascade is allowed
user cascade:'all-delete-orphan' //remove other user references
}
}
I hope you have got ur solution!