This post the dedicated to a formal introduction to hibernate and its features with some important concepts. There will be dedicate post for each of the concept for detailed understanding.
Hibernate is an object-relational mapping (ORM) library for the Java language, providing a framework for mapping an object-oriented domain model to a traditional relational database. Hibernate solves object-relational impedance mismatch problems by replacing direct persistence-related database accesses with high-level object handling functions.
Hibernate’s primary feature is mapping from Java classes to database tables (and from Java data types to SQL data types).
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 permissioned data.
* Enhanced Criteria query API: with full support for projection/aggregation and subselects.
* 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 performant 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 Hibernate’s 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.
I will dedicate a seperate post for the below points, just for quick understanding have a glance at them.
Hibernate Query Language(HQL)
Hibernate also provides data query and retrieval facilities using native sql as well as object query language. There quries are optimzed for databases.
When fully inflated object graph is not loaded, instead only bare required properties are loaded during first access. The whole object graph is loaded lazily only when it is required with its members as collection. An object that doesn’t contain all of the data you need but knows how to get it. It come by default in Hibernate and is useful in performance in one to Many mappings.
Database Independend Quries (Dialet – sql translater)
Hibernate generates the SQL calls and attempts to relieve the developer from manual result set handling and object conversion and keep the application portable to all supported SQL databases with little performance overhead.
Mapping Java classes to database tables is accomplished through the configuration of an XML file or by using Java Annotations. When using an XML file, Hibernate can generate skeletal source code for the persistence classes. This is unnecessary when annotation is used.
Facilities to arrange one-to-many and many-to-many relationships between classes are provided. In addition to managing association between objects, Hibernate can also manage reflexive associations where an object has a one-to-many relationship with other instances of its own type.
Creates Data base Scehma (Reverse Engineering)
Hibernate can use the XML file or the annotation files to create the databases based on the object mapping into the database using reverse engineering. This is the configuration which will create DB tables automatically if they do not exists.