• Skip to primary navigation
  • Skip to content
  • Skip to primary sidebar
  • Skip to footer
  • Core Java
  • Design Patterns
  • JSP
  • Servlets
  • Building Tools
  • jQuery
  • Spring
  • Hibernate
  • Mongo DB
  • More
    • HTML
    • SCJP
    • AJAX
    • UML
    • Struts
    • J2EE
    • Testing
    • Angular JS

J2EE Reference

  • Home
  • About Us
    • Java Learning Centers
  • Contact Us

Setting up Hibernate

May 21, 2015 By j2eereference Leave a Comment

Setting up Hibernate

In this article let’s see how to setup development environment to use hibernate framework with eclipse.

Step1 :

  • Download hibernate jar files: which are required to use hibernate framework. You can download latest version of hibernate jar files from:http://hibernate.org/orm/downloads/

pic1

  • Extract zip file that you downloaded. Inside extracted files:
    •  You can find hibernate-core-5.0.0.Beta2 which is main jar file that is required to use hibernate library.
    • “Lib” folder: contains jars that hibernate requires. It has dependencies of hibernate. Jars that are essential are in the ‘required’ folder and we will also use JPA jar(you can find it within “jpa” folder)

 

Step 2:

  • Open your eclipse: Let’s create new java project with name “FirstHibernateProject”

pic2

  • Right click on project select properties. Within properties go to Java build path and select libraries tab.

pic3

 

  • You can create new library with all required jars, so that you don’t have add jar files each when you are working with hibernate. You can just include this library whenever you are working with hibernate
  • To create new library:
    • Click on Add Library tab and select user library.
    • Click on new and specify library name and click Ok.
  • I have created library with name hibernate (Refer below picture).

pic4

  • After creating library, the next step is to add jar files. Click on “Add JARs”. Select main jar file, required and JPA jar files from extracted files. Click on ok.

pic5

  • Select user library that you created and click on finish

pic6

  • Now you can see that hibernate library is added to your project with all the required jars.

 

Step 3:

  • Before configuring hibernates, prerequisites are:
    • You must have database installed in your machine. So that, we can configure hibernate to connect to database. You can have any database available and configure hibernate to connect to database.
    • Hibernate internally uses JDBC driver to connect to database. So depending on database, you have to provide hibernate the JDBC driver, So that it can use that driver to connect to database.
  • Add your JDBC jar file to a project (Got o properties->Java build path-> libraries-> Add external jars): This will help hibernate to connect to database that you have installed in your machine.

 

Step 4:

  • If you want to change hibernate configuration to another database, you will have to do two things:
    • Install database in your machine.
    • Provide JDBC for that database to hibernate.

This is all the ground work required to configure project that uses hibernate.

We created project, added hibernate jars and JDBC for the database.

Now you are all set to write code that uses hibernate.

Related Posts

  • query by example in hibernate
  • How to call stored procedure in Hibernate
  • get and load in Hibernate
  • projection in hibernate
  • Hibernate NamedNative Query
  • Hibernate Named Query
  • Why Hibernate
  • Hibernate Query cache
  • Second level caching in Hibernate
  • First level caching in Hibernate

Filed Under: Hibernate

Reader Interactions

Leave a Reply Cancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Primary Sidebar

FOLLOW US ONLINE

  • View J2eereference-166104970118637’s profile on Facebook
  • View j2eereference’s profile on Twitter
  • View j2eereference’s profile on LinkedIn

Subscribe by email

Recent posts

  • Java Buzzwords
  • Anonymous Inner Class in Java
  • Network Programming – java.net Package
  • Java Regular Expressions
  • Method Local Inner Class in Java
  • URL Processing in Java
  • Iterator Design Pattern Implementation using Java
  • Strategy Design Pattern Implementation using Java
  • Decorator Design Pattern
  • Adapter Design Pattern Implementation using Java
  • JSF Composite Components
  • JSF UI Components
  • What is JavaServer Faces (JSF)?
  • GOF Design Patterns
  • History and Need for Design Patterns

Footer

Core Java
Design Patterns
JSP
Servlets
HTML
Building Tools
AJAX
SCJP
jQuery
Testing
Spring
UML
Struts
Java Centers
Java Training
Home
About Us
Contact Us
Copyright © j2eereference.com. All right reserved.