You are on page 1of 5

Hibernate Tutorial - javatpoint

Page 1 of 5

Javascript | Ajax | Jaxb | JUnit

Contribute Us | login

Home

Core Java

Servlet

+91-9990449935

Summer / Industrial Training @ JavaTpoint

JavaTpoint

Subscribe Us

0120-4256464

JSP

Struts2

Mail API

Hibernate

Spring

Android

Design Pattern

Quiz

Projects

Interview Q

Comment

Forum

Basics of Hibernate
HB Introduction

Hibernate LOG4J

HB Architecture

Hibernate Spring

Understanding First HB
application

Hibernate EJB
Hibernate Struts

Hibernate Mapping

Java Applications

Hibernate Object

Hibernate with IDE


HB in Eclipse
HB in MyEclipse
Hibernate Application
HB with annotation
HB Web application
HB Generator classes

Hibernate Tutorial

next>>

This hibernate tutorial provides in-depth concepts of Hibernate Framework with


simplified examples. It was started in 2001 by Gavin King as an alternative to EJB2
style entity bean. The stable release of Hibernate till Aug 28, 2013, is hibernate
2.2.5. It is helpful for beginners and experienced persons.

HB Dialects
Hibernate Logging
HB with Log4j 1
HB with Log4j 2

Hibernate Framework
Hibernate framework simplifies the development of java application to interact with
the database. Hibernate is an open source, lightweight, ORM (Object Relational Mapping) tool.

Inheritance Mapping
Table Per Hierarchy
TPH using Annotation

An ORM tool simplifies the data creation, data manipulation and data access. It is a programming technique
that maps the object to the data stored in the database.

Table Per Concrete


TPC using Annotation
Table Per Subclass
TPS using Annotation
Collection Mapping
Mapping List
One-to-many by List
OTM Annotation
Mapping Bag

The ORM tool internally uses the JDBC API to interact with the database.

One-to-many by Bag
Mapping Set
One-to-many by Set

Advantages of Hibernate Framework

Mapping Map
Many-to-many by Map

There are many advantages of Hibernate Framework. They are as follows:

Bidirectional
Lazy Collection
Component Mapping
Association Mapping
One-to-one 1
One-to-one 2
Tx Management
HQL
HCQL
Named Query
Hibernate Caching
Second Level Cache
Integration

1) Opensource and Lightweight: Hibernate framework is opensource under the LGPL license and
lightweight.
2) Fast performance: The performance of hibernate framework is fast because cache is internally used in
hibernate framework. There are two types of cache in hibernate framework first level cache and second level
cache. First level cache is enabled bydefault.
3) Database Independent query: HQL (Hibernate Query Language) is the object-oriented version of SQL.
It generates the database independent queries. So you don't need to write database specific queries. Before
Hibernate, If database is changed for the project, we need to change the SQL query as well that leads to the
maintenance problem.
4) Automatic table creation: Hibernate framework provides the facility to create the tables of the database
automatically. So there is no need to create tables in the database manually.
5) Simplifies complex join: To fetch data form multiple tables is easy in hibernate framework.

Hibernate and Struts


Hibernate and Spring
Interview Questions

6) Provides query statistics and database status: Hibernate supports Query cache and provide statistics
about query and database status.

Upcoming topics in Hibernate Tutorial

Basics of Hibernate
Hibernate Architecture
Here, we will learn what are the major elements of hibernate. There is given two figures to understand the
hibernate architecture.

Steps to create Hibernate Application without IDE

http://www.javatpoint.com/hibernate-tutorial

6/5/2014

Hibernate Tutorial - javatpoint

Page 2 of 5

Here, we will see the 6 steps to connect to the database in java using Hibernate. You may also download the
jar files for hibernate here.

Creating Hibernate Application in Eclipse IDE


In this Hibernate tutorial, we will connect hibernate program with the oracle database using the eclipse IDE.
We will create the hibernate application here step by step.

Creating Hibernate Application in MyEclipse IDE


Here, we will connect hibernate program with the oracle database using the Myeclipse IDE. There is given the
steps to create the hibernate application.

Hibernate with annotation


Here, we will create a simple hibernate application with annotation.

Web application with Hibernate


In this example, we will create a web application using JSP and interact with the database using hibernate
framework.

Generator classes
Here, we will learn about generator classes.

Hibernate Dialects
There are many dialect classes in hibernate. Here, we will learn about the dialect classes.

Enable Logging in Hibernate


Hibernate Logging by log4j using log4j.xml file
Let's see the simple example of logging by log4j using xml file.

Hibernate Logging by log4j using log4j.properties file


Let's see the simple example of logging by log4j using properties file.

Inheritance (IS-A) Mapping


Inheritance Mapping
What is inheritance mapping and what are the ways to implement it.

Table Per Hierarchy using xml file


In this Hibernate tutorial, We will map the inheritance hierarchy in a single table. This uses the concept of
discriminator column.

Table Per Hierarchy using Annotation


By the help of @Inheritance(strategy=InheritanceType.SINGLE_TABLE), @DiscriminatorColumn and
@DiscriminatorValue annotations, we can map table per hierarchy strategy using annotation.

Table Per Concrete class using xml file


In this Hibernate tutorial, We will map the inheritance hierarchy in three tables that have no relation.

Table Per Concrete class using Annotation


@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS) and @AttributeOverrides annotations are used
in table per concrete class strategy.

Table Per Subclass using xml file


In this Hibernate tutorial, We will map the inheritance hierarchy in three tables that have relation.

Table Per Subclass using Annotation


@Inheritance(strategy=InheritanceType.JOINED) and @PrimaryKeyJoinColumn annotations are used in table
per subclass strategy.

Collection (HAS-A) Mapping


Collection Mapping Tutorial
Here, we will see how we can map the collection element of a persistent class.

Mapping List

http://www.javatpoint.com/hibernate-tutorial

6/5/2014

Hibernate Tutorial - javatpoint

Page 3 of 5

Let's map the list element using the mapping file. Here, we are containing the values in the list object not the
entity reference.

One-to-many Mapping using List


Example to map one to many relationship by list.

Mapping Bag
Here, we will map the list element using bag. It is non-indexed collection.

One-to-many Mapping using Bag


Example to map one to many relationship by bag.

Mapping Set
Let's map the set object of a persistent class using set element.

One-to-many Mapping using Set


Example to map one to many relationship by set.

Mapping map in Collection Mapping


Map containing the string objects can be mapped in hibernate using map element of class.

Many-to-many Mapping in hibernate using map


Let's see the example of many-to-many association.

Association (HAS-A) Mapping


One-to-one mapping by many to one example
Example of mapping one to one relationship by many-to-one element.

One-to-one mapping by one to one example


Example of mapping one to one relationship by one-to-one element.

Component Mapping
Component Mapping Tutorial
Let's see what is component mapping.

Hibernate Transaction Management


Transaction Management Example
How transaction is maintained by Hibernate framework.

Hibernate Query Language


HQL Tutorial
Here, we will learn about the HQL. Let's create a simple examples of HQL.

Hibernate Criteria Query Language


HCQL Tutorial
Let's see what is Hibernate Criteria Query Language

Hibernate Named Language


Named Query Tutorial
Here, we will learn about the named query. Let's create a simple example of named query using annotation.

http://www.javatpoint.com/hibernate-tutorial

6/5/2014

Hibernate Tutorial - javatpoint

Page 4 of 5

Hibernate Caching
Caching in Hibernate
Hibernate provides first level cache, second level cache and query cache strategies.

Hibernate Second Level Cache using EH Cache


Let's see the simple example to understand the advantage of second level cache.

Hibernate Integration with other Frameworks


Hibernate and Struts2 Integration Tutorial
Let's see the simple example of hibernate and Struts2 integration.

Hibernate and Spring Integration Tutorial


Let's see the simple example of hibernate and Spring integration.

Reference Links
Hibernate Community
Wikipedia
Next Topic Hibernate Architecture

next>>
Hibernate Java

106

11

Hibernate Example

Share

Hibernate HQL

Hibernate LOG4J

8
186

Tweet

javatpoint.com
Like

116,046 people like javatpoint.com.

Facebook social plugin

Like the www.javatpoint.com on facebook / subscribe to get latest updates

.seuQ weivretnI
PSJ
telvreS
avaJ eroC

stcejjorP
stce orP
stcejjorP
stce orP
stcejorP avaJ eerF

sezz uQ
sezz uQ
sezziiiiuQ
sezz uQ
ziuq PSJ
ziuq telvreS
ziuq avaJ eroC

muroF

slairotuT

.seuQ diordnA
.seuQ etanrebiH
.seuQ gnirpS
.seuQ sturtS
.seuQ PSJ
.seuQ telvreS
.seuQ avaJ eroC

DTL TVP TI SSS


OES
gniniarT
tnempoleveD

lairotuT XAJA
lairotuT C
lairotuT LQS
lairotuT tpircSavaJ
lairotuT diordnA
lairotuT etanrebiH
lairotuT 0.3 gnirpS
lairotuT 0.2 sturtS
lairotuT nrettaP ngiseD
lairotuT IPA liaM
lairotuT PSJ
lairotuT telvreS
lairotuT avaJ eroC

http://www.javatpoint.com/hibernate-tutorial

Blog

6/5/2014

http://www.javatpoint.com/hibernate-tutorial

6/5/2014
.devreseR sthgiR llA
.tnioptavaJ 3102-1102

aidnI ,PU ,700102


, d a b ai z a h G , r a g a N n a h o M
, ll a M X M M r a e N
,daoR TG ,6 - tolP :sserddA
g r o.ti s s s @ y ri u q n e : li a m E
5399440999 19+ : .boM
4646524-0210 : .leT

SU TCATNOC

ziuq DCWCS/PJCO
ziuq diordnA
ziuq 2sturtS

lairotuT nevaM

ycnatlusnoC

lairotuT BXAJ
lairotuT tinUJ

Hibernate Tutorial - javatpoint

Page 5 of 5

You might also like