简体   繁体   English

Grails默认对关联进行排序(双向一对多)

[英]Grails Default Sorting an Association(bidirectional one-to-many)

I am trying to default sort an association, my domain classes are as follows 我正在尝试对关联进行默认排序,我的域类如下

Class Section{
    Integer displayOrder
    static hasMany=[questionCategories:QuestionCategory]

    static mapping={
        questionCategories sort:'displayOrder'
    }
}

Class QuestionCategory{
    Integer displayOrder
    static hasMany=[questions:Question]

    static mapping={
        questions sort:'displayOrder'
    }
}

Class Question{
    Integer displayOrder
}

basically i want to get a list of section objects which is sorted by section class's displayOrder, the inner questionCategories sorted by questionCatgory Class's displayOrder and similarly questions sorted by Question class's displayOrder 基本上我想获取按节类的displayOrder排序的节对象列表,按questionCatgory类的displayOrder排序的内部questionCategories和类似地按Question类的displayOrder排序的问题

I have tried SortedSet approach and that works fine, but unfortunately we cannot use it 我尝试了SortedSet方法,效果很好,但是很遗憾,我们无法使用它

with this configuration i am getting this error 用这种配置我得到这个错误

java.sql.SQLSyntaxErrorException: ORA-00904: "QUESTIONCA3_"."DISPLAY_ORDER": invalid identifier

This looks like your database is not setup correctly. 看来您的数据库设置不正确。 One of your underlying tables doesn't have a "DISPLAY_ORDER" column. 您的基础表之一没有“ DISPLAY_ORDER”列。 Judging by the "QUESTIONCA3_" I'd guess it's the table related to QuestionCategory. 从“ QUESTIONCA3_”来看,我猜这是与QuestionCategory相关的表。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM