Grails映射/排序关联

用户3914455

我上一堂课

static hasMany = [allocations: Allocations]

..和一个映射

static mapping = {
    allocations sort: 'line'
}

我想添加第二个排序字段..类似

static mapping = {
    allocations sort: ['line', 'qty']
}

但是我什么都不能工作(尝试分配排序:([line:'asc',qty:'asc'])和其他)..是否可以通过这种方式对多个属性上的关联进行排序?

BTW在grails 2.3.7上..

谢谢

伊曼纽尔·罗莎(Emmanuel Rosa)

不它不是。sort()仅允许您按单个属性排序。

自定义默认属性[<-单数]以对查询结果进行排序。

https://grails.github.io/grails-doc/latest/ref/Database%20Mapping/sort.html

相反,您可以使用条件查询:

SomeDomain.withCriteria { 
    allocations {
        order('line')
        order('qty')
    }
}

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章