JSF Hibernate Integration (CRUD Example)

JSF Hibernate Integration (CRUD Example)
Code to integrate JSF with Hibernate and perform Create, Read, Update and Delete operations. This code is tested in Netbeans with MySQL Database.

Creating Project:
1) File –>New Project–>Java –>Web Application and click Next
2)Project name as HiberJSF and Click Next
3) Click Next
4) Choose the JSF and Hibernate framework and select the appropriate Database and click Finish

Structure
Structure

Table Creation

NewHibernateUtil.java

hibernate.reveng.xml

Student.hbm.xml

Student.java

Dao.java

index.xhtml

show.xhtml (to display all records)

Output:
Save:
save

ID Name Department
1 Alpha Computer Science
21 Seline Models
90 Sean Physics

Delete
delete

ID Name Department
21 Seline Models
90 Sean Physics

Show Record by ID
showid

Update
update

ID Name Department
21 Christy Planner

Show.xhtml

ID Name Department
21 Christy Planner
90 Sean Physics

 NOTE:
Do not forget to Add @ManagedBean in student.java and import – import javax.faces.bean.ManagedBean; (Not javax.annotation.ManagedBean)

 

 

 

 

 

 

 

 

 

4 thoughts on “JSF Hibernate Integration (CRUD Example)

  1. i am follow this all the concept but is not work in my netbeans can u give a exact code for netbeans 8.0.2 version. and my project shows this error
    An Error Occurred:

    java.lang.IndexOutOfBoundsException: Index: 0, Size: 0

  2. i’ve been build the project that following same like yours, but when runing the program. i got an error : “/index.xhtml @12,61 value=”#{mhs.nim}”: Target Unreachable, identifier ‘mhs’ resolved to null “. the code “Student ID: “, i replaced and changes like : ” ID: ”

    please resolved this error for me….

    sorry #badEnglish

Leave a Reply

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