Session-01. Hibernate Framework ? Why we use Hibernate ?

Post on 23-Dec-2015

246 views 5 download

Transcript of Session-01. Hibernate Framework ? Why we use Hibernate ?

Session-01

Hibernate Framework ?

Why we use Hibernate ?

Example-1

JDBC

MYSQL

SQL SERVER

Oracle

MYSQL Query

SQL SERVER Query

ORACLE Query

Result

Example-2

JDBC

MYSQL

Load DB Driver

Get Connection

Create Statement

SQL Query

SQL Result Set

Oracle

Load DB Driver

Get Connection

Create Statement

SQL Query

SQL Result Set

Result

Example-3

MYSQLJDBC CODE FOR

MYSQL

A.java A.class

ORACLEJDBC CODE FOR

ORACLE

A.java A.class

Compile

Recompile

Result

Solution?

Solution-1 & 2

Hibernate(ORM)

MYSQL

SQL SERVER

Oracle

MYSQL Dialect

SQL SERVER Dialect

ORACLE Dialect

HQL

Solution-3

HibernateConfiguration

File

A.classCompile

MYSQL

XML

A.class

A.class

Oracle

SQL Server

Compile

Compile

Pros and Cons of JDBC

Solution...

ORM

What is ORM?

• ORM stands for Object-Relational Mapping (ORM) is a programming technique

for converting data between relational databases and object oriented

programming languages such as Java, C# etc.

Continue...

Java ORM Frameworks:

Hibernate Overview

• Hibernate framework simplifies the development of java application to interact

with the database.

• Hibernate is an open source, lightweight ORM tool.

Advantages of Hibernate Framework

1) Opensource and Lightweight

2) Fast performance:

The performance of hibernate framework is fast because cache is

internally used in hibernate framework.

3) Database Independent query:

HQL (Hibernate Query Language) is the object-oriented version of SQL.

4) Automatic table creation

5) Simplifies complex join

To fetch data form multiple tables is easy in hibernate framework.

Hibernate Architecture

There are 4 layers in hibernate architecture :

Elements of Hibernate Architecture

Connection Provider

Example