grails has documentation for findAllBy*, but it doesn't tell you what it returns, or how to use it. E.g.
def results = Book.findAllByTitleLike("%Hobbit%)
is results a map? a set? a List? a special object with paging and extra features, and contains a collection of Books?
intellij has no clue what the type or results is (it thinks its a single Book) , the official grails documentation doesn't tell you, Google returns no examples (that I can find), so how could one find such info out?
What is returned if no books are found? Null? and empty collection of some sort? how does one safely determine the number of books found? how does one access the returned books? Are they ordered?
findAllBy returns:
findBy (which is designed to return single items) returns:
If you're curious about object return types in Groovy, you can use the Apache Commons ReflectionToStringBuilder to show you return types:
import org.apache.commons.lang.builder.ReflectionToStringBuilder
...
log.error (new ReflectionToStringBuilder(results).toString())
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With