list
目的 Purpose
Lists instances of the domain class.使用例 Examples
// list everything def results = Book.list()// list 10 results def results = Book.list(max: 10)// list 10 results, offset by 100 def results = Book.list(max: 10, offset: 100)// list 10 results, offset by 100, orderd by title in descending order def results = Book.list(max: 10, offset: 100, sort: "title", order: "desc")// list all books, eagerly fetching the authors association def results = Book.list(fetch: [authors: "eager"])
max
is specified as a named argument this will return a PagedResultList which has a getTotalCount() method to return the total number of matching records for pagination. Two queries are still run, but they're run for you and the results and total count are combined in the PagedResultList
.詳細 Description
パラメータ: Parameters:
max
- The maximum number to listoffset
- The offset from the first result to list fromorder
- How to order the list, either"desc"
or"asc"
sort
- The property name to sort byignoreCase
- Whether to ignore the case when sorting. Default istrue
.fetch
- The fetch policy for the object's associations as aMap
readOnly
- true if returned objects should not be automatically dirty-checked (simlar toread()
)fetchSize
- number of rows fetched by the underlying JDBC driver per round tripflushMode
- HibernateFlushMode
override, defaults toFlushMode.AUTO
timeout
- query timeout in seconds