Chapter 4 Architecture

Source: Internet
Author: User
Chapter 4 Architecture Overview

A very high-level overview of the nhibana architecture:

This figure shows that nhib.pdf uses database and configuration file data to provide persistence services (and persistent objects) for applications ).

We tried to show more details about the NHibernate runtime architecture. But unfortunately, nhib.pdf is flexible and provides several different running methods. Let's take a look at two extreme situations. In a lightweight system, applications provide their own ADO. NET connections and manage transactions. This method uses a minimum subset of the nhib.pdf API.

In a comprehensive solution system, all underlying ADO. NET APIs are abstracted for applications, and NHibernate takes care of all the details for you.

The following are some object definitions in the figure:

SessionFactory ( NHibernate.ISessionFactory)

A thread-safe and immutable cache snapshot for compiled ing files of a single database. It isSessionIsConnectionProvider. You can hold an optional (second-level) data cache and store data that can be reused in transactions at the process or cluster level.

Session, Session ( NHibernate.ISession)

A single thread, short-lived object, represents a conversation between the application and the persistence layer. Encapsulates An ADO. NET connection. YesTransaction. Save the cache of the required (level 1) Persistent object, which is used to traverse the object graph or find the object through the identifier.

Persistent and Its Collections)

Objects of a single thread with short life cycle, including persistence and commercial functions. They may be common objects, and the only thing special is that they now belong to and only belong to oneSession. OnceSessionAre disabled, they will allSessionCan be used freely at any program layer (for example, directly as a DTO or data transmission object transmitted to the presentation layer ).

Temporary Object and its Collection)

CurrentlySession. They may have just been instantiated by the program, but they haven't been made persistent yet, or they may have been turned off by a closedSessionInstantiated.

Transaction ( NHibernate.ITransaction)

(Optional) Single-threaded, short-lived object. The application uses it to represent atomic operations of a batch of jobs. Is the abstraction of the underlying ADO. NET transaction. A Session may span multipleTransactionTransaction.

ConnectionProvider ( NHibernate.Connection.ConnectionProvider)

(Optional) Factory connected by ADO. NET. From the underlyingIDbConnectionAbstract. Invisible to applications, but can be extended/Implemented by developers.

TransactionFactory ( net.sf.hibernate.TransactionFactory)

(Optional) the factory of the transaction instance. Invisible to applications, but can be extended/Implemented by developers.

In the light structure above, the program is not usedTransaction/TransactionFactoryOrConnectionProviderAPI, directly talking to ADO. NET.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.