Interfaces in Hibernate

There are 5 main Interfaces in Hibernate which form its lifeline. All of them are found in the org.hibernate package. An overview of the hibernate APIs can be found at www.hibernate.org

• Configuration interface

o Used to configure hibernate in any java application
o The java application is provided with a JDBC connection and resource mapping using the Configuration API
o It’s the first object a user uses while working with hibernate

• SessionFactory interface

o This interface is used to obtain session objects
o Though it is thread safe, we need one SessionFactory for each database that the application is connecting to.
o It acts as a kind of Cache storage during runtime giving the database sessions available for java objects.

• Session interface

o This is the primary Interface used by hibernate
o It is known as the hibernate’s persistence manager
o It is the interface used to obtain a transaction.
o It is different from the httpSession object and the two should not be confused.
o Session objects are not thread safe

• Transaction interface

o Though an optional API, it performs the all important task of abstracting the application from the underlying complex JDBC or JTA transaction.
o Each transaction object represents an atomic unit of work.
o Each session may have one or more transactions.

• Criteria and Query interface

o Query interface controls the “how” and “what” of executing queries on a database.
o Queries can be written in native SQL or in hibernate query language
o Criteria queries are those created using Java objects and Criteria interface is useful in helping to create them.

Vinay

I am an Oracle ACE in Oracle ADF/Webcenter. Sr Java Consultant-working on Java/J2EE/Oracle ADF/Webcenter Portal/ content and Hibernate for several years. I'm an active member of the OTN JDeveloper/Webcenter forum. Passionate about learning new technologies. I am here to share my knowledge. Give your views and suggestion on [email protected] .

More Posts - Website

Follow Me:
TwitterLinkedInGoogle PlusYouTube