Grail 域模型关联对多个字段进行默认排序
我已经四处寻找在多个字段上对域模型关联进行排序的解决方案,但没有找到单一答案。 这是不是尚未实现的功能,在这种情况下是否有一个“好的”解决方法
我有两个模型:
Board{
static hasMany = [tiles: Tile]
static mapping = {
This is what i would like to do!!
sort x : 'asc'
sort y : 'acs'
}
}
Tile {
int x
int y
}
Ive searched around for a solution on sorting an domain models association on multiple field but not found a single answer.
Is this not feature not yet implemented and in that case is there a 'good' workaround
I have two models:
Board{
static hasMany = [tiles: Tile]
static mapping = {
This is what i would like to do!!
sort x : 'asc'
sort y : 'acs'
}
}
Tile {
int x
int y
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果映射中内置了排序功能,我将无法做到。我使用 Grails 已经快三年了,但还没有看到这一点。但我认为更简单的方法是尝试使用集合排序,并且 Title 实现了类似的功能。然后你做了一个 Collection.sort(tiles);
I am unable if there is a sorting built into the mapping. I been working with Grails for almost 3 years, and have not seen that yet. But i think the easier way to do that is try using collection sort, and Title implements comparable. And you do a Collection.sort(tiles);