Configuring Hibernate in Eclipse
Hibernate is an object/relational mapping tool for Java environments. What does it mean the term object/relational mapping? simply a technique of mapping a data representation from an object model to a relational data model with a SQL-based schema.
Hibernate Installation/Setup on Eclipse IDE
You should download the latest production release of Hibernate from the Hibernate website at http://www.hibernate.org/ orhttp://sourceforge.net/projects/hibernate/files/hibernate3/ and unpack the archive after download.
Create a new Java Project and enter HibernateApplication as project name.
Create lib and src subdirectories in this project. (When you create a new Java Project in Eclipse IDE, src subdirectory will be created automatically.)
Copy JAR files which are listed below, from hibernate distribution that you have downloaded to the lib directory of the “HibernateApplication”project.
Under root directory of the hibernate distrubution:
hibernate3.jar
Under lib/required directory of the hibernate distrubution:
antlr-2.7.6.jar
commons-collections-3.1.jar
dom4j-1.6.1.jar
javassist-3.12.0.GA.jar
jta-1.1.jar
slf4j-api-1.6.1.jar
Under lib/jpa directory of the hibernate distrubution:
hibernate-jpa-2.0-api-1.0.1.Final.jar
Download slf4j-1.6.1.zip file from http://www.slf4j.org/download.html, unpack the archive and copy the slf4j-simple-1.6.1.jar file to lib directory of the “HibernateApplication” project.
slf4j-simple-1.6.1.jar
Additionally, you will need the database driver JAR that Hibernate uses to connect to your database. I use Oracle Express Edition(Oracle XE) and it’s database driver jar is here on Windows:
C:\oraclexe\app\oracle\product\10.2.0\server\jdbc\lib\ojdbc14.jar
Copy this ojdbc14.jar to the lib directory of the “HibernateApplication” project.
After these steps “HibernateApplication” project will look like this:
Now I will create a User library on Eclipse IDE. Then, I will add all JAR files in the HibernateApplication\lib directory to this User library and add this User library to the project build path.
Click Window–>Preferences on the top menu bar of Eclipse.
Click Java–>Build Path–>User Libraries and click New button then enter “Hibernate”
as the User library name.
Select “Hibernate” User library that we just created and click Add JARS… button.
Select all JAR files in the lib folder of the “HibernateApplication” project and click Open button to add all JAR files to “Hibernate” User library.
Now “Hibernate” User library is ready and we can add this User library to “HibernateApplication” project build path.
Right click to “HibernateApplication” project and click Build Path–>Add Libraries
Then, select “User Library” and click Next button.
Finally, select “Hibernate” User library and click Finish button.
After adding “Hibernate” User library to “HibernateApplication” project, it will look like this:
Congratulations, you have installed Hibernate on Eclipse IDE