Hibernate is a JDBC-based database persistence framework. A Hibernate application's Java to SQL mappings are defined in the org.hibernate.cfg.Configuration
object. The mappings are compiled from XML mapping files. A XML mapping file is added to a Configuration
object as follows:
Configuration cfg = new Configuration().addResource("Catalog.hbm.xml");
Hibernate configuration properties, which include JDBC properties, are set using one of the following methods:
1. Set the configuration properties using
setProperties()
method of theConfiguration
object.2. Specify the configuration properties in the
hibernate.properties
file.3. Specify the properties as System properties.
4. Specify the properties in the
hibernate.cfg.xml
file.
A SessionFactory
is used to create and pool connections. A SessionFactory
is created from a Configuration
object as follows:
SessionFactory sessionFactory = cfg.buildSessionFactory();
When a Session
object is created a JDBC connection is obtained from the...