# Best practice for bidirectional associations List vs Set

**URL:** <https://discourse.hibernate.org/t/best-practice-for-bidirectional-associations-list-vs-set/7310>\
**Category:** Hibernate ORM\
**Created:** [February 28, 2023, 9:56am UTC](https://discourse.hibernate.org/t/best-practice-for-bidirectional-associations-list-vs-set/7310 "2023-02-28T09:56:40Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![agreedSkiing](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/agreedskiing/32/2282_2.png) [@agreedSkiing](https://discourse.hibernate.org/u/agreedSkiing)\
**Post date:** [February 28, 2023, 9:56am UTC](https://discourse.hibernate.org/t/best-practice-for-bidirectional-associations-list-vs-set/7310/1 "2023-02-28T09:56:40Z")

</div>

After reading the best parctices section for Hibernate Orm about [associations](https://docs.jboss.org/hibernate/orm/5.6/userguide/html_single/Hibernate_User_Guide.html#best-practices-mapping-associations) and having a discussion with some of my colleagues, we started to wonder what are the best practices for performances for the different associations given if they are bidirectional?

We found an “old” post regarding Hibernate 4.3 ([Hibernate Facts: Favoring bidirectional Set(s) vs List(s)](https://www.javacodegeeks.com/2013/10/hibernate-facts-favoring-bidirectional-sets-vs-lists.html)) but don’t know if that applies to later (5+) Hibernate Orm implementations.

I think there is no need to ask for unidirectional since that is written in the user guide already

> For unidirectional collections, `Set`s are the best choice because they generate the most efficient SQL statements. Unidirectional `List`s are less efficient than a `@ManyToOne` associati

---

<div class="post-metadata">

**Author:** ![beikov](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/beikov/32/258_2.png) [@beikov](https://discourse.hibernate.org/u/beikov)\
**Post date:** [February 28, 2023, 10:10am UTC](https://discourse.hibernate.org/t/best-practice-for-bidirectional-associations-list-vs-set/7310/2 "2023-02-28T10:10:11Z")

</div>

Use a `List` with `@OrderColumn` if the order is relevant to you. Otherwise, use a `Set`. It’s as simple as that 😉

---

<div class="post-metadata">

**Author:** ![agreedSkiing](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/agreedskiing/32/2282_2.png) [@agreedSkiing](https://discourse.hibernate.org/u/agreedSkiing)\
**Post date:** [February 28, 2023, 11:53am UTC](https://discourse.hibernate.org/t/best-practice-for-bidirectional-associations-list-vs-set/7310/3 "2023-02-28T11:53:56Z")

</div>

Well that is good to know know 🙂 then we don’t need to do any changes to our collection mappings.
