Delete object of my domain in grails e groovy

10 показвания
Преминаване към първото непрочетено съобщение

Michele Medas

непрочетено,
23.07.2017 г., 10:29:3823.07.17 г.
до Grails Dev Discuss

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.

Отговор до всички
Отговор до автора
Препращане
0 нови съобщения