Introduction
What is Hibernate ?
Hibernate is a persistent service.
It works with various databases such as Oracle, MySQL, Sybase,
SAP DB, IBM DB2,
MS SQL Server, Postgre SQL.
Hibernate may be used in standalone application and web applications.
Hibernate has to be configured before use.
The table should have a primary key.
First read and understand about Object Relational Mismatch.
Steps in using Hibernate.
01. Reading configuration files
02. Creating SessionFactory
03. Creating Sessions
04. Application specific code
Different layers.
--------------------
Application
--------------------
Session
--------------------
Session Factory
--------------------
Configuration
--------------------
Configuration files
--------------------
In hibernate3 the configuration file is called hibernate.cfg.xml.
The primary purpose of this file is to configure the Hibernate service.
There are 3 methods by which database connection details are intimated
to
Hibernate service.
01. Provided by Hibernate framework in the configuration file.
02. Provided by JNDI datasource in case if you are using J2EE server.
03. Database connection details given by the user.
01. User defined configuration.
Hibernate configuration file has only dialect and resource
mapping.
con = cfg.openSession();
02. Uses database configuration given by configuration file.
This is used in case of standalone applications and non managed
environment.
5 properties
dialect
driver
url
username
password
resource mapping
03. Uses Hibernate with JNDI datasource.
This type of configuration is used with application servers.