Hibernate
Hibernate Framework
(Model Framework/ORM
Framework)
ORM - Object Relation
Mapping)
------------------------------
Features
1) Makes persistence
(INSERT/UPDATE/DELETE) operations transparent (invisible) to developer
In traditional JDBC
program developer used to
-obtain connection via
--DriverManager.getConnection() method (or) via by connection pooling
--Determine to use
Statement or PreparedStatement object
--SQL statement
managements
--Consuming resultset
--ensuring Atomicity
& Consistency
In Hibernate
--we must write one XML
document named "hibernate-cfg.xml" that contains JDBC driver
information
--Write one Java Bean
class for each table whose properties are same as table columns and their types
--Optionally one XML
document that maps each JavaBean to table and its properties, save the document
as Student.hbm.xml file
--Input both cfg.xml and
hbm.xml files to Hibernate classes. Hibernate classes will internally create
conn, stmt etc objects for SQL operations
--If we instantiate
JavaBean, assign all the class instance variables with values and invoke only
one function on hibernate class called save(bean) as argument. Hibernate reads
javabean values, prepares one dynamic SQL statement and inserts record into DB.
--Atomicity and
consistency are managed by hibernate implicitly
--This way hibernate
reduces the JDBC code to do SQL operations on DB
--That means in
Hibernate what developer must do is map one Java class to table. Hibernate maps
the java object to one entity / record in the DB
-Hibernate does
object-entity relation management
-Not only hibernate does
persistence operations, it caches all the objects stored via Hibernate and as
and when the record is modified in the DB, hibernate updates the state of
javabean also. It implicitly avoids inconsistent problems
1) Transparent
persistence operations
2) Object level
relationship instead of maintaining relationship @ DB level. This is to
facilitate portable relationships across all the DBs
3) Instead of fetching
records from the DB using SQL and operating on ResultSet, we can fetch objects
directly from Hibernate using HQL
4) Caching
-Memory level caching
-Disk level caching
No comments:
Post a Comment