findBynull grails code example

Example: findby in grails

def b = Book.findByTitle("The Shining")

    b = Book.findByTitleAndAuthor("The Sum of All Fears", "Tom Clancy")
    b = Book.findByReleaseDateBetween(firstDate, new Date())
    b = Book.findByReleaseDateGreaterThanEquals(firstDate)
    b = Book.findByReleaseDateLessThanEquals(firstDate)
    b = Book.findByTitleLike("%Hard work%")
    b = Book.findByTitleIlike("%Hard work%") // ignores case
    b = Book.findByTitleNotEqual("Harry Potter")
    b = Book.findByReleaseDateIsNull()
    b = Book.findByReleaseDateIsNotNull()
    b = Book.findPaperbackByAuthor("Douglas Adams")
    b = Book.findNotPaperbackByAuthor("Douglas Adams")
    b = Book.findByAuthorInList(["Douglas Adams", "Hunter S. Thompson"])

Tags:

Java Example