In rails,we can use Order.find(:all,:select=>"id,name...... or Order.where(....).select("id,name") to limit the column.
But i can not find the similar way in Grails. so can you give me some help for it? thanks.
In rails,we can use Order.find(:all,:select=>"id,name...... or Order.where(....).select("id,name") to limit the column.
But i can not find the similar way in Grails. so can you give me some help for it? thanks.
There aren't any possible parameters for the Grails dynamic finders to limit the properties returned by the finder. The best alternative I know of is to use projections within a criteria, i.e.
Book.withCriteria {
like 'author', 'Will%'
projections {
property 'title'
property 'author'
}
}
For more, see the criteria reference
.
You can't limit the columns returned when using a dynamic finder like findBy
. Intead you must use either a criteria query with projections, or a HQL query executed with executeQuery