Java Techies- Solution for All
Hibernate
1.1 Introduction of Hibernate
Hibernate is a high-performance Object/Relational persistence and
query service.Hibernate is free software that is distributed under
the GNU Lesser General Public License. Hibernate solves
object-relational impedance mismatch problem.
Learn More... |
1.2 Benefits of ORM/Hiberate
The SQL code / statements in the application can be eliminated
without writing complex JDBC / Entity Bean code. Distributed
transaction can simply be performed by using ORM tools. Hibernate
is an open source ORM tool and a robust framework to perform
ORMapping. Learn More... |
1.3 Drawbacks of using Hibernate
High Level abstraction obscuring what is happening under the hood.
Learn More... |
1.4 Why Hibernate
JDBC maps Java classes to database tables (and from Java data
types to SQL data types) Hibernate automatically generates the SQL
queries. Learn More... |
1.5 High-Level Architecture
High level view shows the Hibernate architecture, how the
Hibernate application work and which steps following. Learn More... |
1.5.1 Minimal Architecture
The "minimal" architecture has the application manage its own JDBC
connections and provide those connections to Hibernate;
additionally the application manages transactions for itself. Learn More... |
The "comprehensive" architecture abstracts the application away
from the underlying JDBC/JTA APIs and allows Hibernate to manage
the details. Learn More... |
1.6 Hibernate Configuration In Eclipse
You need to follow several steps to configure hibernate with eclipse IDE. Firstly you have to download the hibernate jars and then add them to classpath of eclipse. Learn More... |
This is a simple example of hibernate in which you need to make several files to use hibernate framework. Learn More... |
1.7 Hibernate Framework Objects
Hibernate is a persistence framework which is used to persist data from Java environment to database.
Persistence is a process of storing the data to some permanent medium and retrieving it back at any
point of time even after the application that had created the data ended. Learn More... |
1.8 Hibernate Configuration
An instance of org.hibernate.cfg.Configuration represents an
entire set of mappings of an application's Java types to an SQL
database. The org.hibernate.cfg.Configuration is used to build an
immutable org.hibernate.SessionFactory. The mappings are compiled
from various XML mapping files. Learn More... |
1.9 Basic O/R Mapping
Object/relational mappings are usually defined in an XML document.
The mapping document is designed to be readable and hand-editable. Learn More... |
1.10 Hibernate Life cycle
If you do any modifications all the changes will first applied to the object in session cache only . Learn More... |
1.11 Hibernate Example With Annotations And Log4j
This hibernate example use annotations and log4j. In this example you need to make several files to use hibernate framework. Learn More... |
1.12 Hibernate Datatypes
Hibernate datatypes acts as a bridge between the java datatype and database datatype. Based on the dialect, hibernate choose the correct datatype while creating the table in database. Learn More... |
1.12.1 Hibernate Datatypes Example
Hibernate datatype example show the use of date, locale and currency datatypes. Learn More... |
1.13 Hibernate Query Language Language (HQL)
Hibernate Query Language is known as HQL. It is a object oriented query language as similar to SQL [Structural Query Language].
HQL works on persistent object and their properties rather than tables and columns.
HQL queries is converted into SQL queries to perform task in database Learn More... |
1.14 Application Architecture
Application architecture gives the detail structure of the application and layer used in application. Learn More... |
1.14.1 DAO [Data Access Object]
Use DAO to separate Object-Relationship behavior from the rest of your project as it provide high level of data source abstraction.
The DAO manages the connection with the data source to obtain and store data, data could be a persistence object. Learn More... |
1.14.2 AbstractDAO
AbstractDAO is a super class of all other DAO that contains methods for CRUD operation, which are common to all
sub DAO that is all DAO need these method to perform CRUD operation into database. Learn More... |
1.15 Hibernate Criteria Queries
Hibernate provides one of the methods is Criteria API which allows you to build up a
criteria query object programmatically where you can apply filtration rules and logical conditions. Learn More... |
1.16 Hibernate Fetching Strategies
Hibernate uses a fetching strategy to retrieve associated objects if the application needs to navigate the association.
Fetch strategies can be declared in the O/R mapping metadata, or over-ridden by a particular HQL or Criteria query.
Learn More... |
This example shows how Fetch-SELECT strategy work in hibernate and how it different from others fetching strategy. Learn More... |
This example shows how Fetch-JOIN strategy work in hibernate and how it different from others fetching strategy. Learn More... |
This example shows how batch-size=="2" strategy work in hibernate and how it different from others fetching strategy. Learn More... |
This example shows how Fetch-SUBSELECT strategy work in hibernate and how it different from others fetching strategy. Learn More... |
1.17 Hibernate Caching
Hibernate use caching to maintain the performance of an application.
The caching lie between the application and the database to avoid the number of hits to database,
it provide better performance for critical applications. Learn More... |
1.17.1 First-level Cache
The first-level cache is the Session cache and is a mandatory cache through which all requests must pass.
The Session object keeps an object under its own power before committing it to the database. Learn More... |
1.17.2 Second-level Cache
Second level cache is an optional cache and first-level cache
will always be consulted before any attempt is made to locate
an object in the second-level cache. The second-level cache can be
configured on a per-class and per-collection basis and mainly responsible
for caching objects across sessions. Learn More... |
1.17.3 Query-level Cache
Hibernate also implements a cache for query result sets that integrates closely with the second-level cache.
This is an optional feature and requires two additional physical cache regions that hold the cached query results
and the timestamps when a table was last updated. Learn More... |
1.18 Hibernate Reference
This has hibernate related configurations table and other stuff related hibernate framework. Learn More... |
1.19Examples |