2.2 Understanding the architecture
"The programming interfaces are the first thing you have to learn about Hibernate in order to use it in the persistence layer of your application." There are about four types of interfaces:
i) The Session, Transaction, and Query interfaces perform basic CRUD and querying operations.
ii) The Configuration class for "application infrastructure."
iii) Interceptor, Lifecycle, and Validatable characterize callback interfaces.
iv) UserType, CompositeUserType, and IdentifierGenerator are interfaces that extend "Hibernate’s powerful mapping functionality."
"Hibernate makes use of existing Java APIs, including JDBC), Java Transaction API (JTA, and Java Naming and Directory Interface (JNDI). JDBC provides a rudimentary level of abstraction of functionality common to relational databases, allowing almost any database with a JDBC driver to be supported by Hibernate. JNDI and JTA allow Hibernate to be integrated with J2EE application servers."
Most of the important Hibernate interfaces are in the net.sf.hibernate package. Five "core interfaces" form the basis of the majority of Hibernate applications:
i) Session ii) SessionFactory iii) Configuration iv) Transaction v) Query (and Criteria)
Hibernate uses Configuration to instantiate a SessionFactory which is shared among many threads. Each thread gets a lightweight Session object. "Hibernate sessions are not threadsafe and should by design be used by only one thread at a time."
Transaction is optional. "Hibernate applications may choose not to use this interface, instead managing transactions in their own infrastructure code."
"The Lifecycle and Validatable interfaces allow a persistent object to react to events relating to its own persistence lifecycle... The Interceptor interface was introduced to allow the application to process callbacks without forcing the persistent classes to implement Hibernate-specific APIs. Implementations of the Interceptor interface are passed to the persistent instances as parameters."
"A fundamental and very powerful element of the architecture is Hibernate’s notion of a Type. A Hibernate Type object maps a Java type to a database column type (actually, the type may span multiple columns)... Even better, Hibernate supports user-defined custom types. The interfaces UserType and CompositeUserType are provided to allow you to add your own types."