Tutorial Content:
- Introduction to hibernate framework
- Hibernate hello world example in eclipse
- Difference between openSession and getCurrentSession
- Hibernate one to one mapping example
- Hibernate one to many mapping example
- Hibernate many to many mapping example
- Hibernate inheritance:Table per class hierarchy
- Hibernate inheritance:table per subclass
- Hibernate inheritance:Table per concrete class
- Difference between openSession and getCurrentSession
- Difference between get and load
- Spring MVC Hibernate MySQL CRUD example
- Spring Rest hibernate example
After basic understanding of hibernate framework.We are ready to start working on hibernate In this post,we will configure hibernate in eclipse.For configuring hibernate,there are some prerequisites which you need to have on your system.
- Download hibernate framework.(I am using here latest hibernate version 4.1.9)
- Download any database.(I am using here sql server 2005)
- Download JDBC driver for database(I have downloaded jdbc driver for sql server 2005)
- Eclipse ide
- JDK 1.5 or above
Now,In eclipse IDE,click on File->new
Click on other and then select java project
Click on next and Write project name.I have writtern here “Hibernate4HelloWorldProject”
Write folder name as “jars”
click on finish and empy jar folder will be created in src folder.
Now we will add the hibernate 4 libraries to the project. Extract the “hibernate-release-4.1.9.Final” file if you have not extracted. Now go to the “hibernate-release-4.1.9.Final->lib->required” directory and then copy all the jar files (Ctrl+C) and paste on the jars directory (of our project) in the Eclipse IDE.
Also download jdbc driver for your database and copy that jar to jars
Note- location of above jar files may vary from versions to versions. So if you are using other versions than 4.1.9 then you need to find jars in that version.
Now add all the jars to “Java Build Path”. Right click on the “Hibernate4HelloWorldProject” in project explorer and then select properties. Then select “Java Build Path” –> Libraries and then click on the “Add JARs” button. And add all the libraries to Java Build Path.
Click on OK.