在以下代码中,如何删除与作者相关的所有旧商店记录并插入新的
领域类
class Store {
Date dateCreated
Date lastUpdated
static belongsTo = [author: Author]
static constraints = {
}
}
域控制器
def update() {
if (!requestIsJson()) {
respondNotAcceptable()
return
}
def bookInstance = book.get(params.id)
if (!bookInstance) {
respondNotFound params.id
return
}
if (params.version != null) {
if (bookInstance.version > params.long('version')) {
respondConflict(bookInstance)
return
}
}
def stores = bookInstance.stores
//bookInstance.delete(flush:true);
//stores.delete(flush:true);
bookInstance.properties = request.GSON
if (bookInstance.save(flush: true)) {
respondUpdated bookInstance
} else {
respondUnprocessableEntity bookInstance
}
}