Hibernate One To Many Example – Annotation

java

Hibernate one to many mapping is one of the mapping technique you should mastering if you want to develop applications using Hibernate as a data persistence. In this tutorial i will give an example of hibernate one to many mapping with practical example of relation between entity Fakultas and entity Jurusan.

#1 Relation Table Hibernate One To Many

hibernate one to many

From the picture above, it can be inferred that one Fakultas can have many Jurusan

#2 Hibernate One To Many Class Model

Adjusting with the table that we have, we create 2 entity classes which are Fakultas dan Jurusan

class Fakultas

class Jurusan

#3 COnfig File Hibernate One To Many

Put Fakultas and Jurusan class in the config file like this.

hibernate.cfg.xml

#4 Running Hibernate One To Many Application

Happy Coding 😀
Jaya Jaya Wijayanti!

Facebook Comments
 

Agung Setiawan

Halo, perkenalkan saya Agung Setiawan. Seorang software developer, penulis buku, blogger, gunpla builder, tech educator dan yang paling penting console gamer.

 
Halo, perkenalkan saya Agung Setiawan.
Seorang software developer, penulis buku, blogger, gunpla builder, tech educator dan yang paling penting console gamer.
Selain di blog ini saya cukp aktif juga main di Twitter @agungsetiawanmu dan Facebook serta Instagram.
Mau belajar programming bareng? Cek YouTube channel saya.
Mau belajar Vim bareng saya?

Leave a Reply

Your email address will not be published. Required fields are marked *