Reputation: 3784
In order to refresh a domain object i.e to re-read the data from database we do refresh().
def b = Book.get(1)
…
b.refresh()
I am wondering whether we can refresh a property of the domain.
Suppose i have bound params to Book object and suppose i want to unbind the author property from the book object then is it possible to achieve that?
Let's consider the Book is defined as
class Book {
String title
String author
String category
}
Suppose I do bindData(bookInstance, params). This will bind to all properties. I want to unbind the author after bindData. Is this possible?
Upvotes: 2
Views: 98
Reputation: 3784
I solved this by using bookInstance.author = bookInstance.getPersistentValue('author')
.
Upvotes: 1
Reputation: 19682
It sounds like you just want to exclude binding a particular property.
bindData(bookInstance, params, [exclude: 'author'])
will bind all of the Book
properties except for those listed.
You can conversely use include
to explicitly list which properties to bind from params
.
bindData(bookInstance, params, [include: 'title', 'category'])
Upvotes: 1