Hibernate Set Or List

2019-06-15 07:43发布

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

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


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

Thanks.

1条回答
迷人小祖宗
2楼-- · 2019-06-15 08:29

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

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.

查看更多
登录 后发表回答