給定一個域類:可以更改域對象字段導致grails域被認爲是修改/髒?
class Book {
def title
Author author
}
class Author {
def name
}
鑑於一本書實例:
Author author = new Author(name: 'joe')
author.save()
Book book = new Book(author:author, title: 'groovy book')
book.save()
如果我改變了作者的名字:
author.name = 'john'
是本書認爲髒?或修改?
如果你希望它們被持久化,'title'和'name'屬性應該被賦予'String'類型,而不是'def' – 2014-09-29 20:29:32