"id, na...">

Does Grails have a domain.find-by ... option ": select" to limit columns like rails?

In rails, we can use Order.find (: all,: select => "id, name ...... or Order.where (....). Select (" id, name ") to restrict the column.

But I can't seem to find anything like this in Grails. so can you help me? thank.

+3


source to share


2 answers


There are no possible parameters for dynamic Grails crawlers to limit the properties returned by the crawler. The best alternative I know is to use criteria-based predictions i.e.

Book.withCriteria {
    like 'author', 'Will%'
    projections {
        property 'title'
        property 'author'
    }
}

      



For details see criteria reference

.

+3


source


You cannot limit the columns returned when using a dynamic type lookup findBy

. Intead you have to use either a predictive criteria query or an HQL query executed with executeQuery



+1


source







All Articles