Thursday 4 May 2017

Hibernate architecture

High-level view of the Hibernate architecture:

Minimal subset of Hibernate's APIs
The "minimal" architecture has the application provide its own JDBC connections and manage its own transactions.




Comprehensive architecture
The "comprehensive" architecture abstracts the application away from the underlying JDBC/JTA APIs and allows Hibernate to manage the details.


SessionFactory (org.hibernate.SessionFactory)
A threadsafe, immutable cache of compiled mappings for a single database. A factory for Session and a client of ConnectionProviderSessionFactory can hold an optional (second-level) cache of data that is reusable between transactions at a process, or cluster, level.

Session (org.hibernate.Session)
A single-threaded, short-lived object representing a conversation between the application and the persistent store. It wraps a JDBC connection and is a factory for TransactionSession holds a mandatory first-level cache of persistent objects that are used when navigating the object graph or looking up objects by identifier.

Persistent objects and collections
Short-lived, single threaded objects containing persistent state and business function. These can be ordinary JavaBeans/POJOs. They are associated with exactly one Session. Once the Session is closed, they will be detached and free to use in any application layer (for example, directly as data transfer objects to and from presentation).

Transient and detached objects and collections
Instances of persistent classes that is not currently associated with a Session. They may have been instantiated by the application and not yet persisted, or they may have been instantiated by a closed Session.

Transaction (org.hibernate.Transaction)
(Optional) A single-threaded, short-lived object used by the application to specify atomic units of work. It abstracts the application from the underlying JDBC, JTA or CORBA transaction. A Session might span several Transactions in some cases. However, transaction demarcation, either using the underlying API or Transaction, is never optional.

ConnectionProvider (org.hibernate.connection.ConnectionProvider)
(Optional) A factory for, and the pool of, JDBC connections. It abstracts the application from underlying Datasource or DriverManager. It is not exposed to the application, but it can be extended and/or implemented by the developer.

TransactionFactory (org.hibernate.TransactionFactory)
(Optional) A factory for Transaction instances. It is not exposed to the application, but it can be extended and/or implemented by the developer.


No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...