Hibernate is concerned with helping your application to achieve persistence. Persistence simply means that we would like our application's data to outlive the applications process. Specifically, Hibernate is concerned with data persistence as it applies to relational databases.
Hibernation provides relational persistence for Java and .NET through Object/Relational mapping.
Hibernate is concerned with helping your application to achieve persistence. Persistence simply means that we would like our application's data to outlive the applications process. Specifically, Hibernate is concerned with data persistence as it applies to relational databases.
'Object-Relational Impedance Mismatch' (sometimes called the 'paradigm mismatch') is just a fancy way of saying that object models and relational models do not work very well together. Drums represent data in a tabular format (a spreadsheet is a good visualization for those not familiar with Drums), whereas object-oriented languages, such as Java, represent it as an interconnected graph of objects. Loading and storing graphs of objects using a tabular relational database exposes us to 5 mismatch problems...
1. Granularity
Sometimes you will have an object model which has
more classes than the number of corresponding tables in the database (we says
the object model is more granular than the relational model). Take for
example the notion of an Address...
2. Subtypes (inheritance)
Inheritance is a natural paradigm in
object-oriented programming languages. However, Drums do not define
anything similar on the whole (yes some databases do have subtype support but
it is completely non-standardized)...
3. Identity
A RDBMS defines exactly one notion of 'sameness':
the primary key. Java, however, defines both object identity (a==b) and
object equality (a.equals(b)).
Hibernate 3.0, the latest Open Source persistence
technology at the heart of J2EE. EJB 3.0 is available for download from Hibernet.org.The Hibernate 3.0 core is
68,549 lines of Java code together with 27,948 lines of unit tests, all freely
available under the LGPL, and has been in development for well over a year.
Hibernate maps the Java classes to the database tables. It also provides the
data query and retrieval facilities that significantly reduce the development
time. Hibernate is not the best solutions for data centric applications
that only uses the stored-procedures to implement the business logic in database. It is
most useful with object-oriented domain modes and business logic in the
Java-based middle-tier. Hibernate allows transparent persistence that enables
the applications to switch any database. Hibernate can be used in Java Swing
applications, Java Servlet-based applications, or J2EE applications using EJB
session beans.
Features
of Hibernate
- Hibernate
3.0 provides three full-featured query facilities: Hibernate Query Language, the newly enhanced Hibernate Criteria Query API, and
enhanced support for queries expressed in the native SQL dialect of the database.
- Filters
for working with temporal (historical), regional or permission data.
- Enhanced
Criteria query API: with full support for projection/aggregation and sub
selects.
- Runtime
performance monitoring: via JMX or local Java API, including a
second-level cache browser.
- Eclipse
support, including a suite of Eclipse plug-ins for working with Hibernate
3.0, including mapping editor, interactive query prototyping, schema
reverse engineering tool.
- Hibernate
is Free under LGPL: Hibernate can be used to develop/package and
distribute the applications
for free.
- Hibernate
is Scalable: Hibernate is very per formant and due to its dual-layer
architecture can be used in the clustered environments.
- Less Development
Time: Hibernate reduces the development timings as it supports
inheritance, polymorphism, composition and the Java Collection framework.
- Automatic
Key Generation: Hibernate supports the automatic generation of primary key
for your.
- JDK
1.5 Enhancements: The new JDK has been released as a preview earlier this
year and we expect a slow migration to the new 1.5 platform throughout
2004. While Hibernate3 still runs perfectly with JDK 1.2, Hibernate3 will
make use of some new JDK features. JSR 175 annotations, for example, are a
perfect fit for Hibernate metadata and we will embrace them aggressively.
We will also support Java generics, which basically boils down to allowing
type safe collections.
- EJB3-style
persistence operations: EJB3 defines the create() and merge()
operations, which are slightly different to Hibernates saveOrUpdate()
and saveOrUpdateCopy()
operations. Hibernate3 will support all four operations as methods of the Session
interface.
- Hibernate XML
binding enables data to be represented as XML and POJOs interchangeably.
- The EJB3
draft specification support for POJO persistence and annotations.
To use Hibernate, it is required to create Java classes that represents the
table in the database
and then map the instance variable in the class with the columns in the
database. Then Hibernate can be used to perform operations on the database like
select, insert, update and delete the records in the table. Hibernate
automatically creates the query to perform these operations.
Hibernate architecture has three main components:
·
Connection Management
Hibernate Connection management service provide efficient management of the
database connections. Database connection is the most expensive part of
interacting with the database as it requires a lot of resources of open and
close the database connection.
·
Transaction management:
Transaction management service provides the ability to the user to execute more
than one database statements at a time.
·
Object relational mapping:
Object relational mapping is technique of mapping the data representation from
an object model to a relational data model. This part of the hibernate is used
to select, insert, update and delete the records form the underlying table.
When we pass an object to a Session. Save() method, Hibernate reads the
state of the variables of that object and executes the necessary query.
Hibernate is very good tool as far as object relational mapping is concern,
but in terms of connection management and transaction management, it is lacking
in performance and capabilities. So usually hibernate is being used with other
connection management and transaction management tools. For example apache DBCP
is used for connection pooling with the Hibernate.
Hibernate provides a lot of flexibility in use. It is called "Lite"
architecture when we only use the object relational mapping component. While in
"Full Cream" architecture all the three component Object
Relational mapping, Connection Management and Transaction Management) are used.
Detailed features are available at
Related Links