Hibernate is a powerful high-performance
Object/Relational persistence and query service for Java applications. In
Hibernate it maps object oriented classes to the database tables and also provides
data query. It’s so simple and easy.
Before come to Hibernate, I’ll
get some time to explain where it is come from.
There are some mismatches,
when mapping object oriented classes and relational databases. Here we want to
use a technique to map them correctly. So Object Relational Mapping here. Object
Relational Mapping is used for avoid following mismatches between object
oriented classes and relational data bases.
There may be more classes
than the number of corresponding tables in the data base. Relational data bases
do not defined any similarity to inheritance which is main concept in OOP. RDBMS
only has concept of sameness while OOP has object identity and object equality.
RDBMS is used foreign key for association columns while OOP is used object reference.
The method of access to object class and RDBMS is different.
For more clear, I’ll give
you a example for class and data base table.
public class Student {
private int id;
private
String name;
private int telno;
public
Student() {}
public
Student(String name,int telno) {
this.name = name;
this.telno = telno;
}
public int getId() {
return
id;
}
public
String getName() {
return
name;
}
public int getTelno() {
return
telno;
}
}
Above program is Java student class and By creating a
object we are going to store data in following table.
create table STUDENT (
id INT NOT NULL
auto_increment,
name VARCHAR(30)
default NULL,
telno INT default NULL,
PRIMARY KEY (id)
);
There are some advantages
over traditional JDBC (Java Data Base connectivity). There are no need to deal
with data base implementation. It hides details of SQL queries from OO logic. Entities
are based on business concepts rather than database structure. It is
developed application faster.
There
are many Java ORM Frameworks. Here we use Hibernate framework which provide
services to store and retrieve objects from relational data base.
Hibernate exist between java objects and database server
to handle object –relational mechanisms and patterns by mapping java classes to
database tables and from java data types to SQL data types.
Hibernate
supports RDBMS like MySQL,
Oracle, HSQL Database Engine, DB2/NT, PostgreSQL, FrontBase, Microsoft SQL
Server Database, Sybase SQL Server , Informix Dynamic Server and technologies like
J2EE, Eclipse plug-ins, XDoclet Springand, Maven.
No comments:
Post a Comment