关于hibernate集合的排序问题

来源:互联网 发布:小视频模板软件 编辑:程序博客网 时间:2024/06/05 01:09

1.order-by:这个设置,在继承体系下有缺陷,具体见下列配置:
<many-to-one name="parentType">
    <column name="PARENT_ID"
            not-null="false"/>
</many-to-one>

<set    name="childTypes"
        inverse="true"
        lazy="true"
        batch-size="10"
        cascade="save-update"
        order-by="NAME asc">
    <key column="PARENT_ID"/>
    <one-to-many class="PdsType"/>
</set>
这里的问题是:NAME不是PdsType类映射表的字段,而是父类映射表的字段,所以这里没办法使用order-by来操作,只能使用sort=""来解决

2.sort:可以设置的值:unsorted,natural或者是实现comparator接口的类.只能在jdk1.4以上的jvm中运行

原创粉丝点击