Delete object of my domain in grails e groovy

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Delete object of my domain in grails e groovy

Michele Medas

Using grails I build this domains:

class Book {
    String title
}

class Author {
    String name

        static hasMany = [books: Book]
}


def book1 = new Book(title: "The Shining")

def author1 = new Author (name: "Stephen King")
author1.addToBooks(book1)

If try to delete Author1

author.books.clear()
Author1.delete flush:true

Get this error:

Message null Caused by Referential integrity constraint violation: "FKQG8TLCGMC6WKG6ILECFOXSLVS: PUBLIC.PROJECT_BOOK FOREIGN KEY(BOOK_AUTHOR_ID) REFERENCES PUBLIC.PROJECT_AUTHOR(ID) (1)"; SQL statement: delete from project_column where id=? and version=? [23503-195]

I would like to delete an author without deleting the books.

--
You received this message because you are subscribed to the Google Groups "Grails Dev Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/grails-dev-discuss/48797ce6-3a33-4858-b8f9-91f808ba90ca%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.