gorm - Grails, querying self-referencing table -
i have table self-referencing field:
class book{ integer id string name book version } when add books without "version", version field null have query book table records don't have version (their version field null), following code won't work:
def results = book.withcriteria{ eq("version", "null") } but i'm getting exception:
org.hibernate.propertyaccessexception: illegalargumentexception occurred calling getter of book.id what query should use?
version keyword in gorm used optimistic locking. modify domain , criteria below make criteria return appropriate results.
//domain
class book { integer id string name book bookversion } //criteria
def book = new book(name: "test", version: null) book.id = 1 book.save(flush: true) def results = book.withcriteria{ isnull("bookversion") } assert results && results[0] instanceof book also note, bookversion in question of type book, cannot compared string null.
Comments
Post a Comment