In last section,we discussed the CRUD method in Grails.Now,we'll learn one .of the most powerfull concept of GORM (findBy* method).Following figure shown a example method.
This figure from the book:the definitive guid to grails.
Now I list the available Dynamic Finder method and example:
Expression Arguments Example
Between 2 Project.findByCreateDateBetween(today-10,today)
Equals 1 Project.findByTitleEquals('App1')
GreaterThan 1 Project.findByCreateDateGreaterThan(lastmonth)
GreaterThanOrEqual 1 Project.findByCreateDateGreaterThanOrEqual(lastmon)
IsNull 1 Project.findByTitleIsNull()
IsNotNull 1 Project.findByTitleIsNotNull()
LessThan 1 Project.findByCreateDateLessThan(lastmonth)
LessThanOrEqual 1 Project.findByCreateDateLessThanOrEqual(lastmonth)
Like 1 Project.findByTitleLike('App1%')
NotEqual 1 Project.findByTitleNotEqual('App1')
All of findBy* method only return that fisrt be found object.
There are two cousins method findAllBy* and countBy*.
findAllBy* :return a list that is matched the query logic
countBy* :return a number that is matched result total.
Sunday, March 16, 2008
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment