Pages

Showing posts with label Hibernate. Show all posts
Showing posts with label Hibernate. Show all posts

Friday, July 9, 2010

Hibernate

Hibernate is a Java framework that provides OR mapping functionality to define how Java objects are stored, modified, deleted, and retrieved.

The Hibernate architecture has 3 main components:
  • connection management
  • transaction management
  • object-relational mapping
Hibernate uses POJO classes and XML mapping files to map to database tables.

The Hibernate Session is the main runtime interface between a Java application and Hibernate. SessionFactory allows the application to create a Hibernate Session by reading the configuration from hibernate.cfg.xml.

Important elements of the Hibernate mapping file include the following:
  • <hibernate-mapping> root element
  • <class> maps classes to DB entities
  • <id> maps to the primary key of a table
  • <generator> is used to generate the primary key for a new record. Values include increment, sequence, and assigned
  • <property> maps attributes to columns
HQL is based on the relational object models and makes SQL object-oriented. It uses classes and proeprties instead of tables and columns. It supports polymorphism, associations, etc. and returns results as objects. It is also database independent.

Hibernate also supports native SQL statements.
 
Powered by Blogger