我在长期更新 grails 中的一个域(图书馆)时遇到问题,我试图在添加新书后更新我的图书馆,但添加的书没有得到保存。
I have mapping of bookCollection in my domain Class Library as below:
@OneToMany(cascade = CascadeType.ALL, mappedBy = "Library")
Collection<Book> bookCollection;
I am trying to add a new book to my Library(Initially there is no book in bookColletion):
Library library = Library.get(1)
Book book=Book.get(1)
library.bookCollection.add(book)
and update it:
library.save(flush:true,failOnError: true)
Library is got saved but my book is not.
I am using grails and JPA.
谢谢