Search code examples
grailsgrails-orm

How not to delete a child object when parent is deleted?


I have this class

class Vote {    
    Post post
}

When I delete an object of Vote it should not cascade delete Post.

How can I do it?


Solution

  • I assume you are asking about Grails, not groovy. If yes, then in order to leave the Post instance in the DB, you need to remove static belongsTo = [ vote:Vote ] from the Post class

    P.S. it's good to provide a bit more information on your problem, so we don't have to play guess-game here...