groovy - Order is not working with criteria in Grails -
i have started working groovy , grails , has confusion on order clause criteria.
below code,
def order = "rollnumber" def orderby = "asc" studentlistcriteria = students.createcriteria() int max = 6 int offset = params?.offset ? integer.valueof(params.offset) : 0 def studentlist = studentlistcriteria.list(max: max, offset: offset) { , { eq("isactive", boolean.true ) } order(order,orderby) }
while executing it's throw below error.
groovy.lang.missingmethodexceptionmessageno signature of method: java.lang.string.call() applicable argument types: (java.lang.string, java.lang.string) values: [rollnumber, asc] possible solutions: wait(), any(), tr(java.lang.string, java.lang.string), trim(), find(), size()
can suggest doing wrong here??
please check below code, can not use keywords here.
def orderparameter = "rollnumber"//change name of variable. def orderbyparameter = "asc" studentlistcriteria = students.createcriteria() int max = 6 int offset = params?.offset ? integer.valueof(params.offset) : 0 def studentlist = studentlistcriteria.list(max: max, offset: offset) { , { eq("isactive", boolean.true ) } order(orderparameter,orderbyparameter) }
here, using order
variable. please change name of , go.
Comments
Post a Comment