Hibernate Annotations Tutorial

Hibernate Annotations Tutorial explains step by step details of setting / configuring Hibernate with Eclipse

Hibernate is popular open source ORM (Object Relation Mapping) tool for Java platform, for mapping an entity to a traditional relational database like Oracle, MySQL etc

By using Hibernate, we can done database operations like Create, Read, Update & Delete etc, with very little code.

We can also use Hibernate Query Language (HQL) for the jdbc operation, if you are using HQL, then you can follow this example of Hibernate Query Tutorial

You can also view  Hibernate Tutorial


You can also check following related Hibernate Tutorial Series

1)    Hibernate One To One Relation Mapping Example
2)    Hibernate One To Many Relation Mapping Example
3)    Hibernate Many To One Relation Mapping Example
4)    Hibernate Many To Many Relation Mapping Example
Required Libraries

You need to download

  1. JDK 6
  2. Eclipse 3.7
  3. Hibernate 3.6.8

Following jar must be in classpath

  1. antlr-2.7.6.jar
  2. commons-collections-3.1.jar
  3. javassist-3.12.0.GA.jar
  4. jta-1.1.jar
  5. hibernate-jpa-2.0-api-1.0.1.Final.jar
  6. hibernate3.jar
  7. mysql-connector-java-5.1.18-bin.jar
  8. dom4j-1.6.1.jar
  9. slf4j-api-1.6.1.jar

Hibernate Annotation Required Libraries

Starting with version 3.5, Annotations and EntityManager have been merged back into the Hibernate Core code base as individual modules so following jar's are not needed,


I am creating a sample project that persists Student object (simple POJO (Plain Old Java Object)) into database using hibernate.

Firstly create a Java Project (File->New->Project), select Java Project and click next, provide name as "HibernateExample" according to following screenshot

Create Hibernate Project Hibernate Tutorial


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
        "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
        <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
        <property name="hibernate.connection.url">jdbc:mysql://localhost/test</property>
        <property name="hibernate.connection.username">root</property>
        <property name="connection.password">root</property>
        <property name="connection.pool_size">1</property>
        <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
        <property name="show_sql">true</property>
        <property name="hbm2ddl.auto">create</property>
        <mapping class="com.javatips.student.Student"/>

1 2 3 Next

Your email address will not be published. Required fields are marked *