list 休眠设置或列表

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9188718/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-11 01:46:56  来源:igfitidea点击:

Hibernate Set Or List

hibernatelistset

提问by SP M

Can anybody know when to use Set and when to use List in hibernate mapping file ?

任何人都可以知道何时在休眠映射文件中使用 Set 以及何时使用 List 吗?

<set name="" table="">
    <key>
        <column name="" />
    </key>
</set>


<list name="" cascade="all">
    <key column="" />
    <index column="" />
    <one-to-many class=""/>
</list>

Thanks.

谢谢。

回答by nolt2232

Take a look at this post: @OneToMany List<> vs Set<> difference

看看这个帖子:@OneToMany List<> vs Set<> 区别

The main difference is that a list has ordering while a set does not. Also, a set cannot have duplicate values, while a list can.

主要区别在于列表具有排序,而集合没有。此外,集合不能有重复值,而列表可以。