one-to-many Mapping by List in Hibernate

one-to-many Mapping by List in Hibernate
one-to-many Mapping by List in Hibernate. This code is tested using NetBeans.

You can use List when you want to allow Duplicate items and to store in Ascending Order

NetBeans
1) File–>New–>Java–>Web Application–> Next
2) Give application a name
3) Next–>Next–> Choose Hibernate Framework and select the database to connect

Inside Source Packages create a folder named “pojo”
Inside pojo create 3 Java Class files
1) Exam.java
2) Results.java
3)save.java

Exam.java

Results.java

Right click source packages –>New–>Hibernate Mapping Wizard
hibernate.hbm.xml

hibernate.cfg.xml

save.java

Output:

Exam Table

id Subjects
1 JSP
2 Hibernate

Results Table

id StudentName Marks StudentID Type
1 Alpha 92 1 0
2 Delta 89 2 0

Leave a Reply

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