教你如何set排序!

来源:互联网 发布:the thick of it 编辑:程序博客网 时间:2024/06/05 03:28

我的项目用了s2sh所以,处理是用得hibernate,这样就很容易了,我在相应的实体entity的xml这样定义:

 <set name="xtRoleses" inverse="true" table="role_right" catalog="syxt" order-by="pid asc">
            <key>
                <column name="pid" not-null="true" />
            </key>
            <many-to-many entity-name="com.syxt.Entity.XtRoles" order-by="pid asc">
                <column name="rid" not-null="true" />
            </many-to-many>
        </set>

当然我们也可以建一个list,然后我便利set,然后按照我需要的条件,分别把我的数据加到list里边。然后我在取list。但是你实际操作会发现做这个很难,有的同志会放到map里。这个表用了递归,自己作为自己的外键。取的时候通过外键取东西都是set。所以对set排序一下。

原创粉丝点击