Wednesday, June 18, 2014

How to run first program of Hibernate : A beginner's guide

4:26 PM

Before we proceed further on how to start with hibernate and how to execute your first hibernate program.Please make sure that you have following software ready.

1. Java 1.6 or +
2. MySQL 5 or +/Oracle 10G

Make sure you have Employee table with eid, first_name, last_name. email column. 

Step by step procedure of how to run first hibernate program

  1. Download latest version of hibernate software (jar files) from

  2. Unzip the zip file which you downloaded in step 1.

  3. Add all jar files of hibernate-search-4.5.1.Final\dist\lib\required folder to class path,separated by semi colon.

  4. Add jar files of hibernate-search-4.5.1.Final\dist folder to class path, separated by semi colon.

  5. If you are using Oracle as your database then also add oracle related jar file to class path.

  6. Create a directory for all hibernate related programs you will practice from here onward.
Your directory structure should look like this.

  • is a simple Java file which have getter and setter methods.(All members of this class should be non-static only)

  • Hibernate.cfg.xml is a hibernate configuration file, which contains property related information.Like DB software related url, driver information etc.

  • is a hibernate mapping file, which is used to map java pojo class( members with Database table column.

  • is a java file which contains hibernate based persistence logic.

Download above mentioned all 4 file here: 

Compile both java file and run.

If you run into any problem , feel free to ask .(If possible attach screen shot of the problem)


Post a Comment


© 2014 DieHardTechy . All rights resevered. Designed by Diehardtechy