Question

Is there a shorter/cleaner way than DomainClass.findAll()[0] to retrieve the first domain object in the set of domain objects that would normally be retrieved by findAll()?

Ideally, I'd like DomainClass.find() but such a finder does not exist.

Was it helpful?

Solution

Couldn't you use find without a where clause: http://grails.org/doc/1.1.1/ref/Domain%20Classes/find.html

e.g. DomainClass.find('from DomainClass')

OTHER TIPS

How about using list:

DomainClass.list(max:1)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top