Create a java project
Type java in the wizards
Give the Name as Hibernate3.0
And click finish For installation unzip the downloaded files.
Now configure Eclipse with Hibernate
Create the user libraries to the project
Click on Windows -> preferences, type User and select User Libraries
Create a new User Library
Give Name of Library for Example (Hibernate 3.0) and say OK
In that library add all the jar files. (Make sure you select Hibernate 3.0)
Go to Hibernate distribution folder and select hibernate3.0.jar,
Select in lib->required folder select select all the files,
Again go to lib -> bytecode -> cglib -> cglib-2.2.jar
Select Hibernate Annotations -> hibernate-annotations.jar
Hibernate Annotations -> lib -> ejb3-persistence.jar and
Hibernate Annotations -> lib -> test -> slf4j.log4j12.jar and log4j.jar
Totally there will be 13 jar files
You have created the user library, now integrate user library with Eclipse
Select JEE or JAVA perspective, on the project click on properties, select java build path,
Under that select libraries, click on Add Library (on right)
Select User Library & click next
select Hibernate3.0(which is created)
Next you have to configuration with Database and Hibernate
We have to use hibernate configuration file we need (hibernate.cfg.xml) file, this will help us to make the connection between Hibernate and Database
We can copy from the existing downloads of Hibernate Distribution, goto Project, select some tutorials, src, main, resources, and you find the file.(hibernate.cfg.xml, log4j.properties) copy both
Right click on the src folder on your eclipse project and paste on that.
Now open hibernate.cfg.xml, and now we have to configure, goto source
In the file find for the property tag with “connection .driver_class” and chage the Class name which you have, and same for URL, UserName, Pwd
To find the dialect -> goto userlibrary, Hibernate3.0, and you see that it will be some where in org.hibernate.(some thing), in hibernate3.jar you will find the dialect matching your Database, and type the same in the file.
And make an entry in the configuration file In current_session_context_class as thread And rest keep it as it is Comment the code property hbm2ddl.auto (because we will create the database) And mapping resources as well since we will use our own mappings (annotations).
Note: To comment select the text and go to source and add Block Comment or ctrl+shift+/
End of configuration.
See More Links On: