class Person {
    String firstName
    String lastName
    Integer age
}第一个
用途
检索模型类第一个实例。
示例
在模型类中
// retrieve the first person ordered by the identifier
def p = Person.first()
// retrieve the first person ordered by the lastName property
p = Person.first(sort: 'lastName')
// retrieve the first person ordered by the lastName property
p = Person.first('lastName')参数
- 
sort(可选) - 排序属性
另请参阅
| 请注意,对于使用联合主键的模型类,不支持 first() 和 last() 方法。 |