# Zero to many relationship in hibernate

**URL:** <https://discourse.hibernate.org/t/zero-to-many-relationship-in-hibernate/5000>\
**Category:** Hibernate ORM\
**Created:** [February 1, 2021, 12:44pm UTC](https://discourse.hibernate.org/t/zero-to-many-relationship-in-hibernate/5000 "2021-02-01T12:44:10Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Swarnkar](https://avatars.discourse-cdn.com/v4/letter/s/f4b2a3/32.png) [@Swarnkar](https://discourse.hibernate.org/u/Swarnkar)\
**Post date:** [February 1, 2021, 12:44pm UTC](https://discourse.hibernate.org/t/zero-to-many-relationship-in-hibernate/5000/1 "2021-02-01T12:44:10Z")

</div>

hey,  
I have a requirement for zero to many relationship could u please help how to do it in unidirectional and bidirectional mappings.  
any reference documents welcome.

---

<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 2, 2021, 8:54am UTC](https://discourse.hibernate.org/t/zero-to-many-relationship-in-hibernate/5000/2 "2021-02-02T08:54:14Z")

</div>

There are plenty of articles and books you can find online. Here you can find the official Hibernate documentation: [Documentation - 5.4 - Hibernate ORM](http://hibernate.org/orm/documentation/5.4/)

---

<div class="post-metadata">

**Author:** ![Swarnkar](https://avatars.discourse-cdn.com/v4/letter/s/f4b2a3/32.png) [@Swarnkar](https://discourse.hibernate.org/u/Swarnkar)\
**Post date:** [February 3, 2021, 10:51am UTC](https://discourse.hibernate.org/t/zero-to-many-relationship-in-hibernate/5000/3 "2021-02-03T10:51:55Z")

</div>

> [@beikov](#):
>
> Documentation - 5.4 - Hibernate ORM

@beikov that is in general but i want a example for zero to many mapping

---

<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 3, 2021, 11:11am UTC](https://discourse.hibernate.org/t/zero-to-many-relationship-in-hibernate/5000/4 "2021-02-03T11:11:57Z")

</div>

I don’t want to be rude, but if you have no idea about JPA/Hibernate you should maybe first start reading a book about it and discover all the mapping possibilities, otherwise you will “learn” things by example which might give you a wrong intuition about how it is supposed to work.

Anyway, here are plenty of examples for one-to-many associations: [Java Persistence/OneToMany - Wikibooks, open books for an open world](https://en.wikibooks.org/wiki/Java_Persistence/OneToMany)

A zero-to-many association is not a real thing. You can either model many-to-many associations, or one-to-many associations. The only thing that could be “zero” i.e. optional is the FK in a one-to-many association on the many-side.
