Share on Google+Share on Google+

Hibernate Getting Started

In this Hibernate Getting Started you will quickly download the a Hibernate running example project and run on your machine.

Hibernate Getting Started


Hibernate Getting Started

In this Hibernate Getting Started you will quickly download the a Hibernate running example project and run on your machine.

After completing this tutorial you should be able to run the hibernate based application from Eclipse Environent.

Let's get started with the fast track Hibernate Getting Started tutorial.

What is required?

  • I am assuming that Java is installed and configured on your computer.
  • MySQL database is installed on your computer.
  • Latest version of Eclipse is installed and configured on your computer.

Downloading the project

Download the Hibernate Getting Started project. Save the file into hard disk and extract.

Opening the project in Eclipse:

Open eclipse and select File --> New --> Java Project. This will open the wizard as shown below:

Now Select "Create project from existing source" and enter the path where you have extracted the code. In My case it is C:\copyhere\hibernategettingstarted\HibernateGettingStarted. As shown below:

Now Click on the Finish button.

Your project is ready.

Create database
I am assuming that MySQL is installed on the local host. Create new database using following command:

create database hibernatetutorial;

Open hibernate.cfg.xml file and change the database access username and password if it is different.

<property name="hibernate.connection.url">jdbc:mysql://localhost/hibernatetutorial</property>

<property name="hibernate.connection.username">root</property>

<property name="hibernate.connection.password">root</property>

Now everything is set and you can run the example code.

Running the Example

Open in eclipse IDE and then run as shown below:

In the Eclipse console you will find the following output:

log4j:WARN No appenders could be found for logger (org.hibernate.cfg.Environment).

log4j:WARN Please initialize the log4j system properly.

Inserting Record


Hibernate: insert into CONTACT (FIRSTNAME, LASTNAME, EMAIL, ID) values (?, ?, ?, ?)


In this short tutorial we learned how to run the Hibernate application from Eclipse IDE. You can continue learning hibernate tutorial at



Posted on: October 20, 2010 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Share this Tutorial Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Discuss: Hibernate Getting Started  

Post your Comment

Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
May 27, 2011
hibernate tutorial

properly explained
Ertavf Timu├žin
October 9, 2011
Commit missed?

org.hibernate.Transaction tx = session.beginTransaction(); tx.commit(); Those two lines are missed in this example, does not inserts values
Aaron Evans
March 12, 2012
but it doesn't work

It compiles, it prints, but it doesn't save to the database. And it doesn't throw any errors or warnings.
March 24, 2012
Problem in running above example

This code is not running. It's throwing NullPointerException at session.flush() in
October 9, 2012

This tutorial very good and usefull for me thank you. please give any other tutorial that display some data which is already in database table.
Larry Scott
October 5, 2013
nice tutorial, butt does not work

Nice tutorial, very straight forward. When I run, it runs without any errors, but I see no tables or data in my hibernatetutorial database