Grails 映射/排序关联
Grails mapping / sorting associations
在 class 我有
static hasMany = [allocations: Allocations]
.. 和映射
static mapping = {
allocations sort: 'line'
}
我想添加第二个排序字段.. 类似
static mapping = {
allocations sort: ['line', 'qty']
}
但我什么都做不了(试过分配排序:([行:'asc',数量:'asc'])和其他)..是否可以对关联进行排序不止一个 属性 这样吗?
顺便说一句,Grails 2.3.7 ..
谢谢
不,不是。 sort()
允许您仅按单个 属性.
排序
Customizes the default property [ <--singular] to sort by for query results.
https://grails.github.io/grails-doc/latest/ref/Database%20Mapping/sort.html
相反,您可以使用条件查询:
SomeDomain.withCriteria {
allocations {
order('line')
order('qty')
}
}
在 class 我有
static hasMany = [allocations: Allocations]
.. 和映射
static mapping = {
allocations sort: 'line'
}
我想添加第二个排序字段.. 类似
static mapping = {
allocations sort: ['line', 'qty']
}
但我什么都做不了(试过分配排序:([行:'asc',数量:'asc'])和其他)..是否可以对关联进行排序不止一个 属性 这样吗?
顺便说一句,Grails 2.3.7 ..
谢谢
不,不是。 sort()
允许您仅按单个 属性.
Customizes the default property [ <--singular] to sort by for query results.
https://grails.github.io/grails-doc/latest/ref/Database%20Mapping/sort.html
相反,您可以使用条件查询:
SomeDomain.withCriteria {
allocations {
order('line')
order('qty')
}
}