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.
There are plenty of articles and books you can find online. Here you can find the official Hibernate documentation: Documentation - 5.4 - Hibernate ORM
@beikov that is in general but i want a example for zero to many mapping
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
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.