1
- ---
2
- layout:
3
- ---
1
+ <!doctype html>
4
2
< html > < head >
5
3
< meta charset ="utf-8 ">
6
4
< meta name ="viewport " content ="width=device-width, initial-scale=1 " />
7
5
< meta http-equiv ="X-UA-Compatible " content ="IE=edge ">
8
6
< meta http-equiv ="content-type " content ="text/html;charset=utf-8 " />
9
- < title > Chapter 2. Architecture</ title > < link rel ="stylesheet " href ="../shared/css/html.css " type ="text/css "> < meta name ="generator " content ="DocBook XSL Stylesheets V1.65.1 "> < link rel ="home " href ="index.html " title ="NHibernate - Relational Persistence for Idiomatic .NET "> < link rel ="up " href ="index.html " title ="NHibernate - Relational Persistence for Idiomatic .NET "> < link rel ="previous " href ="quickstart.html " title ="Chapter 1. Quickstart with IIS and Microsoft SQL Server "> < link rel ="next " href ="session-configuration.html " title ="Chapter 3. ISessionFactory Configuration "> </ head > < body bgcolor ="white " text ="black " link ="#0000FF " vlink ="#840084 " alink ="#0000FF "> < div class ="navheader "> < table width ="100% " summary ="Navigation header "> < tr > < th colspan ="3 " align ="center "> Chapter 2. Architecture</ th > </ tr > < tr > < td width ="20% " align ="left "> < a accesskey ="p " href ="quickstart.html "> Prev</ a > </ td > < th width ="60% " align ="center "> </ th > < td width ="20% " align ="right "> < a accesskey ="n " href ="session-configuration.html "> Next</ a > </ td > </ tr > </ table > < hr > </ div > < div class ="chapter " lang ="en "> < div class ="titlepage "> < div > < div > < h2 class ="title "> < a name ="architecture "> </ a > Chapter 2. Architecture</ h2 > </ div > </ div > < div > </ div > </ div > {% include google_adsense.html %}< div class ="sect1 " lang ="en "> < div class ="titlepage "> < div > < div > < h2 class ="title " style ="clear: both "> < a name ="architecture-overview "> </ a > 2.1. Overview</ h2 > </ div > </ div > < div > </ div > </ div > < p >
7
+ < title > Chapter 2. Architecture</ title > < link rel ="stylesheet " href ="../shared/css/html.css " type ="text/css "> < meta name ="generator " content ="DocBook XSL Stylesheets V1.65.1 "> < link rel ="home " href ="index.html " title ="NHibernate - Relational Persistence for Idiomatic .NET "> < link rel ="up " href ="index.html " title ="NHibernate - Relational Persistence for Idiomatic .NET "> < link rel ="previous " href ="quickstart.html " title ="Chapter 1. Quick-start with IIS and Microsoft SQL Server "> < link rel ="next " href ="session-configuration.html " title ="Chapter 3. ISessionFactory Configuration "> </ head > < body bgcolor ="white " text ="black " link ="#0000FF " vlink ="#840084 " alink ="#0000FF "> < div class ="navheader "> < table width ="100% " summary ="Navigation header "> < tr > < th colspan ="3 " align ="center "> Chapter 2. Architecture</ th > </ tr > < tr > < td width ="20% " align ="left "> < a accesskey ="p " href ="quickstart.html "> Prev</ a > </ td > < th width ="60% " align ="center "> </ th > < td width ="20% " align ="right "> < a accesskey ="n " href ="session-configuration.html "> Next</ a > </ td > </ tr > </ table > < hr > </ div > < div class ="chapter " lang ="en "> < div class ="titlepage "> < div > < div > < h2 class ="title "> < a name ="architecture "> </ a > Chapter 2. Architecture</ h2 > </ div > </ div > < div > </ div > </ div > < div class ="sect1 " lang ="en "> < div class ="titlepage "> < div > < div > < h2 class ="title " style ="clear: both "> < a name ="architecture-overview "> </ a > 2.1. Overview</ h2 > </ div > </ div > < div > </ div > </ div > < p >
10
8
A (very) high-level view of the NHibernate architecture:
11
9
</ p > < div class ="mediaobject " align ="center "> < img src ="../shared/images/overview.png " align ="middle "> </ div > < p >
12
10
This diagram shows NHibernate using the database and configuration data to
21
19
The "full cream" architecture abstracts the application away from the
22
20
underlying ADO.NET APIs and lets NHibernate take care of the details.
23
21
</ p > < div class ="mediaobject " align ="center "> < img src ="../shared/images/fullcream.png " align ="middle "> </ div > < p >
24
- Heres some definitions of the objects in the diagrams:
22
+ Here are some definitions of the objects in the diagrams:
25
23
26
24
</ p > < div class ="variablelist "> < dl > < dt > < span class ="term "> ISessionFactory (< tt class ="literal "> NHibernate.ISessionFactory</ tt > )</ span > </ dt > < dd > < p >
27
25
A threadsafe (immutable) cache of compiled mappings for a single database.
51
49
(Optional) A single-threaded, short-lived object used by the application to
52
50
specify atomic units of work. Abstracts application from underlying ADO.NET
53
51
transaction. An < tt class ="literal "> ISession</ tt > might span several
54
- < tt class ="literal "> ITransaction</ tt > s in some cases.
52
+ < tt class ="literal "> ITransaction</ tt > s in some cases. Transaction scopes may be used
53
+ instead.
55
54
</ p > </ dd > < dt > < span class ="term "> IConnectionProvider (< tt class ="literal "> NHibernate.Connection.IConnectionProvider</ tt > )</ span > </ dt > < dd > < p >
56
55
(Optional) A factory for ADO.NET connections and commands. Abstracts application
57
- from the concrete vendor-specific implementations of < tt class ="literal "> IDbConnection </ tt >
58
- and < tt class ="literal "> IDbCommand </ tt > . Not exposed to application, but can be
56
+ from the concrete vendor-specific implementations of < tt class ="literal "> DbConnection </ tt >
57
+ and < tt class ="literal "> DbCommand </ tt > . Not exposed to application, but can be
59
58
extended/implemented by the developer.
60
59
</ p > </ dd > < dt > < span class ="term "> IDriver (< tt class ="literal "> NHibernate.Driver.IDriver</ tt > )</ span > </ dt > < dd > < p >
61
60
(Optional) An interface encapsulating differences between ADO.NET providers, such
88
87
The instance was once associated with a persistence
89
88
context, but that context was closed, or the instance
90
89
was serialized to another process. It has a persistent
91
- identity and, perhaps, a corrsponding row in the database.
90
+ identity and, perhaps, a corresponding row in the database.
92
91
For detached instances, NHibernate makes no guarantees
93
92
about the relationship between persistent identity and
94
93
CLR identity.
101
100
Starting with version 1.2, NHibernate added the < tt class ="literal "> ISessionFactory.GetCurrentSession()</ tt >
102
101
method. The processing behind < tt class ="literal "> ISessionFactory.GetCurrentSession()</ tt > is pluggable.
103
102
An extension interface (< tt class ="literal "> NHibernate.Context.ICurrentSessionContext</ tt > ) and a new
104
- configuration parameter (< tt class ="literal "> hibernate. current_session_context_class</ tt > ) have been added
103
+ configuration parameter (< tt class ="literal "> current_session_context_class</ tt > ) have been added
105
104
to allow pluggability of the scope and context of defining current sessions.
106
105
</ p > < p >
107
106
See the API documentation for the < tt class ="literal "> NHibernate.Context.ICurrentSessionContext</ tt >
110
109
tracking the current contextual session. Out-of-the-box, NHibernate comes with several
111
110
implementations of this interface:
112
111
</ p > < div class ="itemizedlist "> < ul type ="disc "> < li > < p >
112
+ < tt class ="literal "> NHibernate.Context.AsyncLocalSessionContext</ tt > - current sessions are tracked
113
+ by current asynchronous flow. You are responsible to bind and unbind an
114
+ < tt class ="literal "> ISession</ tt > instance with static methods of class
115
+ < tt class ="literal "> CurrentSessionContext</ tt > . Binding operations from inner flows will not be
116
+ propagated to outer or siblings flows. Added in NHibernate 5.0.
117
+ </ p > </ li > < li > < p >
113
118
< tt class ="literal "> NHibernate.Context.CallSessionContext</ tt > - current sessions are tracked
114
- by < tt class ="literal "> CallContext</ tt > . You are responsible to bind and unbind an < tt class =" literal " >
115
- ISession</ tt > instance with static methods of class < tt class =" literal " > CurrentSessionContext
116
- </ tt > .
119
+ by < tt class ="literal "> CallContext</ tt > . You are responsible to bind and unbind an
120
+ < tt class =" literal " > ISession</ tt > instance with static methods of class
121
+ < tt class =" literal " > CurrentSessionContext < /tt > .
117
122
</ p > </ li > < li > < p >
118
123
< tt class ="literal "> NHibernate.Context.ThreadStaticSessionContext</ tt > - current session is
119
- stored in a thread-static variable. This context only supports one session factory.
124
+ stored in a thread-static variable. This context supports multiple session factory only
125
+ since NHibernate v5.
120
126
You are responsible to bind and unbind an < tt class ="literal "> ISession</ tt > instance with
121
127
static methods of class < tt class ="literal "> CurrentSessionContext</ tt > .
122
128
</ p > </ li > < li > < p >
123
- < tt class ="literal "> NHibernate.Context.WebSessionContext</ tt > -
124
- stores the current session in < tt class ="literal "> HttpContext</ tt > .
125
- You are responsible to bind and unbind an < tt class ="literal "> ISession</ tt >
126
- instance with static methods of class < tt class ="literal "> CurrentSessionContext</ tt > .
129
+ < tt class ="literal "> NHibernate.Context.WebSessionContext</ tt > -
130
+ stores the current session in < tt class ="literal "> HttpContext</ tt > .
131
+ You are responsible to bind and unbind an < tt class ="literal "> ISession</ tt >
132
+ instance with static methods of class < tt class ="literal "> CurrentSessionContext</ tt > .
127
133
</ p > </ li > < li > < p >
128
134
< tt class ="literal "> NHibernate.Context.WcfOperationSessionContext</ tt > - current sessions are tracked
129
135
by WCF < tt class ="literal "> OperationContext</ tt > . You need to register the < tt class ="literal "> WcfStateExtension</ tt >
130
- extension in WCF. You are responsible to bind and unbind an < tt class ="literal "> ISession
131
- </ tt > instance with static methods of class < tt class ="literal "> CurrentSessionContext</ tt > .
136
+ extension in WCF. You are responsible to bind and unbind an < tt class ="literal "> ISession</ tt >
137
+ instance with static methods of class < tt class ="literal "> CurrentSessionContext</ tt > .
132
138
</ p > </ li > < li > < p >
133
139
< tt class ="literal "> NHibernate.Context.ManagedWebSessionContext</ tt > - current
134
- sessions are tracked by < tt class ="literal "> HttpContext</ tt > . Removed in NHibernate 4.0
135
- - < tt class ="literal "> NHibernate.Context.WebSessionContext</ tt > should be used instead.
136
- You are responsible to bind and unbind an < tt class ="literal "> ISession</ tt > instance with static methods
140
+ sessions are tracked by < tt class ="literal "> HttpContext</ tt > . Removed in NHibernate 4.0
141
+ - < tt class ="literal "> NHibernate.Context.WebSessionContext</ tt > should be used instead.
142
+ You are responsible to bind and unbind an < tt class ="literal "> ISession</ tt > instance with static methods
137
143
on this class, it never opens, flushes, or closes an < tt class ="literal "> ISession</ tt > itself.
138
144
</ p > </ li > </ ul > </ div > < p >
139
- The < tt class ="literal "> hibernate. current_session_context_class</ tt > configuration parameter
145
+ The < tt class ="literal "> current_session_context_class</ tt > configuration parameter
140
146
defines which < tt class ="literal "> NHibernate.Context.ICurrentSessionContext</ tt > implementation
141
147
should be used. Typically, the value of this parameter would just name the implementation
142
148
class to use (including the assembly name); for the out-of-the-box implementations, however,
143
- there are corresponding short names: "call", "thread_static", "web" and "wcf_operation",
149
+ there are corresponding short names: < tt class ="literal "> async_local</ tt > , < tt class ="literal "> call</ tt > ,
150
+ < tt class ="literal "> thread_static</ tt > , < tt class ="literal "> web</ tt > and < tt class ="literal "> wcf_operation</ tt > ,
144
151
respectively.
145
- </ p > </ div > </ div > < div class ="navfooter "> < hr > < table width ="100% " summary ="Navigation footer "> < tr > < td width ="40% " align ="left "> < a accesskey ="p " href ="quickstart.html "> Prev</ a > </ td > < td width ="20% " align ="center "> < a accesskey ="u " href ="index.html "> Up</ a > </ td > < td width ="40% " align ="right "> < a accesskey ="n " href ="session-configuration.html "> Next</ a > </ td > </ tr > < tr > < td width ="40% " align ="left " valign ="top "> Chapter 1. Quickstart with IIS and Microsoft SQL Server </ td > < td width ="20% " align ="center "> < a accesskey ="h " href ="index.html "> Home</ a > </ td > < td width ="40% " align ="right " valign ="top "> Chapter 3. ISessionFactory Configuration</ td > </ tr > </ table > </ div > {% include google_analytics.html %}{% include metrika_yandex_ru.html %} </ body > </ html >
152
+ </ p > </ div > </ div > < div class ="navfooter "> < hr > < table width ="100% " summary ="Navigation footer "> < tr > < td width ="40% " align ="left "> < a accesskey ="p " href ="quickstart.html "> Prev</ a > </ td > < td width ="20% " align ="center "> < a accesskey ="u " href ="index.html "> Up</ a > </ td > < td width ="40% " align ="right "> < a accesskey ="n " href ="session-configuration.html "> Next</ a > </ td > </ tr > < tr > < td width ="40% " align ="left " valign ="top "> Chapter 1. Quick-start with IIS and Microsoft SQL Server </ td > < td width ="20% " align ="center "> < a accesskey ="h " href ="index.html "> Home</ a > </ td > < td width ="40% " align ="right " valign ="top "> Chapter 3. ISessionFactory Configuration</ td > </ tr > </ table > </ div > </ body > </ html >
0 commit comments