Saturday, April 16, 2011

Hibernate : Core Interfaces

Following are Core interfaces provided by Hibernate API
org.hibernate.Session
org.hibernate.SessionFactory
org.hibernate.Criteria
org.hibernate.Query
  1. The Session is main runtime interface between a Java application and Hibernate. This is a persistence manager that manages operation like storing and retrieving objects. Instances of Session are inexpensive to create and destroy. They are not thread safe.
  2. The main contract here is the creation of Session instances. Usually an application has a single SessionFactory instance and threads servicing client requests obtain Session instances from this factory. SessionFactory instances are not lightweight and typically only one instance is created for the whole application. If the application accesses multiple databases, then it needs to be one per database.
  3. Criteria is a simplified API for retrieving entities by composing Criterion objects. The Session is a factory for Criteria. Criterion instances are usually obtained via the factory methods on Restrictions. This provides a provision for conditional search over the resultset. 
  4. Query represents object oriented representation of a Hibernate query. A Query instance is obtained by calling Session.createQuery().

No comments:

Post a Comment