Difference between findAll, getAll and list in Grails

后端 未结 3 1169
借酒劲吻你
借酒劲吻你 2021-01-30 08:28

With Grails there are several ways to do the same thing.

Finds all of domain class instances:

Book.findAll()
Book.getAll()
Book.list()

3条回答
  •  悲哀的现实
    2021-01-30 09:20

    AFAIK, these are all identical

    Book.findAll()
    Book.getAll()
    Book.list()
    

    These will return the same results

    Book.findById(1)
    Book.get(1)
    

    but get(id) will use the cache (if enabled), so should be preferred to findById(1)

提交回复
热议问题