Hibernate Reference Manual (Chapter 1)

zhaozj2021-02-08  255

Hibernate reference manual

First chapter architecture

1.1 overview

Hibernate architecture:

It can be seen from the above figure, Hibernate uses databases and configuration data to provide data continuous service (and continuous objects) for applications.

Since Hibernate has configurable and supports multiple implementations, we will display the detailed architecture of Hibernate during runtime from both extremes. "Lightweight" architecture will provide JDBC connections and manage your own transactions by the application. This implementation uses the minimum collection of Hibernate APIs:

The "heavyweight" architecture abstracts the underlying JDBC / JTA interface and follows these details from Hibernate:

Below is the definition of some objects in the figure:

Net.sf.hibernate.SessionFactory

Net.sf.hibernate.Session

Net.sf.hibernate.Transaction

Net.sf.hibernate.TransactionFactory

Net.sf.hibernate.Connection.ConnectionProvider

Persistent Objects and Collect Objects And Collectes

Transient Objects and Collectes

l SessionFactory

After compiling, thread secure mapping cache, used to generate a customer of a session, a customer of the ConnectionProvider object.

l session

Used to describe a single-threaded, short-term object that sessions between applications and continuous objects. This object is packaged, and the transaction factory is managed for the application.

l Persistent Objects and Collectes

Single-threaded, short-term objects that accommodate persistent states and business functions. They may be ordinary JavaBeans, the only special is that they are associated with the session.

l Transient Objects and Collectes

There is no instance of continuous classes associated with the session. They may be instantiated by the application but not continuous, or may be instantiated by a closed session.

l Transaction

(Optional) is used by the application to specify the single-threaded, short-term objects of the atom work unit. Abstract underlying JDBC, JTA or CORBA transaction request. A session can span several transactions.

l ConnectionProvider

(Optional) Generate a plant that is a JDBC connection. Abstract DataSource or DriverManager request. Do not expose the interface to the application.

l TransactionFactory

(Optional) Factory that produces a transaction. Do not expose the interface to the application.

In the "Lightweight" architecture, the application passes the Transaction / TransactionFactory and / or the ConnectionProvider interface with JTA or JDBC direct session.

1.2 Continuous Object Logo

Applications may access the same object as the continuous state in two sessions. But in any case, the continued class instance will never share it in two session instances. There are two ways to identify objects:

Persistent Identity: foo.getid (). Equals (bar.getid ())

JVM Identity: foo == bar

At this time, the object returned from a specific session is equal. However, when the application accesses the "Persistent Identity" business object in two sessions, two instances will differ (JVM Identity).

This approach entrusts Hibernate and databases to pay attention to concurrency (as long as each session is in single-thread, the application does not need to synchronize any business object) or object identity (in the same session, the application can be safely used safely == To compare the object) problem. 1.3 JMX integration

JMX is a standard for J2EE to manage Java components. Hibernate can be managed through the JMX standard MBean, but because most application servers do not support JMX, Hibernate also provides some non-standard configuration mechanisms.

to be continued……

转载请注明原文地址:https://www.9cbs.com/read-1181.html

New Post(0)