첫 번째 일치 찾기 -Domainclass.findall () [0]에 대한 대안
문제
더 짧고 깨끗한 방법이 있습니까? DomainClass.findAll()[0]
일반적으로 검색되는 도메인 객체 세트에서 첫 번째 도메인 객체를 검색하려면 findAll()
?
이상적으로는 싶습니다 DomainClass.find()
그러나 그러한 파인더는 존재하지 않습니다.
해결책
Where 절 없이는 찾을 수 없습니까? http://grails.org/doc/1.1.1/ref/domain%20classes/find.html
예 : domainclass.find ( '도메인 클래스에서')
다른 팁
사용하는 것은 어떻습니까 list
:
DomainClass.list(max:1)
제휴하지 않습니다 StackOverflow