Search code examples
grailsgrails-orm

Can changes to domain object fields cause a grails domain to be considered modified/ dirty?


Given a domain class:

class Book {
    def title
    Author author
}

class Author {
   def name
}

Given a book instance:

Author author = new Author(name: 'joe')
author.save()
Book book = new Book(author:author, title: 'groovy book')
book.save()

If I change the name of the author:

author.name = 'john'

Is the book considered dirty? or modified?


Solution

  • No, the book is not considered dirty in this case since the book is already saved. Only the author is considered dirty. Given that no properties of the book have changed and only a property of the author has.