Book Image

JDBC 4.0 and Oracle JDeveloper for J2EE Development

Book Image

JDBC 4.0 and Oracle JDeveloper for J2EE Development

Overview of this book

Table of Contents (20 chapters)
JDBC 4.0 and Oracle JDeveloper for J2EE Development
Credits
About the Author
About the Reviewer
Preface

Hibernate and JDBC


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. 1. Set the configuration properties using setProperties() method of the Configuration object.

  2. 2. Specify the configuration properties in the hibernate.properties file.

  3. 3. Specify the properties as System properties.

  4. 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...