For example I've been written a simple domain-class:
class Book{
String bookName
}
I've done some records of this instance. And now I wanna update one of them, to realize it, I've an idea to write a setter for bookName
. But may be is more elegant method to do this via GORM-methods?
Grails uses the Groovy method - getter and setters are created for you and you can take it that they are available for your use on each property of a domain class that you create. See http://www.groovy-lang.org/style-guide.html section 7.
Alfredo suggested one way in which you can get one instance of the Book class, but to use this you need a mechanism in place to obtain the id so that you can use the get() method.
If you want to get an instance of book by its name, you can use dynamic finders. See 6.4.1 Dynamic Finders of http://grails.github.io/grails-doc/latest/guide/GORM.html#finders.
The simplest one to use would be to use this to get your book instance:
def bookInstance= Book.findByBookName('the book name that you want to change')
You can then update it as has already been described.