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

Agung Setiawan adalah software engineer di BukaLapak.com, penulis sekaligus pecinta sastra, dan pembaca buku

 
Halo, perkenalkan saya Agung Setiawan.
Saya Software Engineer di BukaLapak.
Simak pemikian saya soal dunia Software Engineering via Twitter di @agungsetiawanmu dan facebook
Blog ini saya update seminggu sekali jadi sering-sering saja mampir
Mau belajar Vim bareng saya?
Belajar ngoding dari nol menggunakan PHP

Leave a Reply

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