forked from nhibernate/nhibernate-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathISessionFactory.cs
233 lines (206 loc) · 8.94 KB
/
ISessionFactory.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data.Common;
using NHibernate.Connection;
using NHibernate.Engine;
using NHibernate.Metadata;
using NHibernate.Stat;
namespace NHibernate
{
/// <summary>
/// Creates <c>ISession</c>s.
/// </summary>
/// <remarks>
/// <para>
/// Usually an application has a single <c>SessionFactory</c>. Threads servicing client requests
/// obtain <c>ISession</c>s from the factory. Implementors must be threadsafe.
/// </para>
/// <para>
/// <c>ISessionFactory</c>s are immutable. The behaviour of a <c>SessionFactory</c>
/// is controlled by properties supplied at configuration time.
/// These properties are defined on <c>Environment</c>
/// </para>
/// </remarks>
public partial interface ISessionFactory : IDisposable
{
/// <summary>
/// Obtain a <see cref="ISession"/> builder.
/// </summary>
/// <returns>The session builder.</returns>
ISessionBuilder WithOptions();
// Obsolete in v5.
/// <summary>
/// Open a <see cref="ISession"/> on the given connection
/// </summary>
/// <param name="connection">A connection provided by the application</param>
/// <returns>A session</returns>
/// <remarks>
/// Note that the second-level cache will be disabled if you
/// supply a ADO.NET connection. NHibernate will not be able to track
/// any statements you might have executed in the same transaction.
/// Consider implementing your own <see cref="IConnectionProvider" />.
/// </remarks>
[Obsolete("Please use WithOptions instead.")]
ISession OpenSession(DbConnection connection);
// Obsolete in v5.
/// <summary>
/// Create database connection and open a <see cref="ISession"/> on it, specifying an interceptor
/// </summary>
/// <param name="sessionLocalInterceptor">A session-scoped interceptor</param>
/// <returns>A session.</returns>
[Obsolete("Please use WithOptions instead.")]
ISession OpenSession(IInterceptor sessionLocalInterceptor);
// Obsolete in v5.
/// <summary>
/// Open a <see cref="ISession"/> on the given connection, specifying an interceptor
/// </summary>
/// <param name="conn">A connection provided by the application</param>
/// <param name="sessionLocalInterceptor">A session-scoped interceptor</param>
/// <returns>A session.</returns>
/// <remarks>
/// Note that the second-level cache will be disabled if you
/// supply a ADO.NET connection. NHibernate will not be able to track
/// any statements you might have executed in the same transaction.
/// Consider implementing your own <see cref="IConnectionProvider" />.
/// </remarks>
[Obsolete("Please use WithOptions instead.")]
ISession OpenSession(DbConnection conn, IInterceptor sessionLocalInterceptor);
/// <summary>
/// Create a database connection and open a <see cref="ISession"/> on it
/// </summary>
/// <returns>A session.</returns>
ISession OpenSession();
/// <summary>
/// Obtain a <see cref="IStatelessSession"/> builder.
/// </summary>
/// <returns>The session builder.</returns>
IStatelessSessionBuilder WithStatelessOptions();
/// <summary>
/// Get a new <see cref="IStatelessSession"/>.
/// </summary>
/// <returns>A stateless session</returns>
IStatelessSession OpenStatelessSession();
/// <summary>
/// Get a new <see cref="IStatelessSession"/> for the given ADO.NET connection.
/// </summary>
/// <param name="connection">A connection provided by the application</param>
/// <returns>A stateless session</returns>
IStatelessSession OpenStatelessSession(DbConnection connection);
/// <summary>
/// Get the <see cref="IClassMetadata"/> associated with the given entity class
/// </summary>
/// <param name="persistentClass">the given entity type.</param>
/// <returns>The class metadata or <see langword="null"/> if not found.</returns>
/// <seealso cref="IClassMetadata"/>
IClassMetadata GetClassMetadata(System.Type persistentClass);
/// <summary> Get the <see cref="IClassMetadata"/> associated with the given entity name </summary>
/// <param name="entityName">the given entity name.</param>
/// <returns>The class metadata or <see langword="null"/> if not found.</returns>
/// <seealso cref="IClassMetadata"/>
IClassMetadata GetClassMetadata(string entityName);
/// <summary>
/// Get the <c>CollectionMetadata</c> associated with the named collection role
/// </summary>
/// <param name="roleName"></param>
/// <returns></returns>
ICollectionMetadata GetCollectionMetadata(string roleName);
/// <summary>
/// Get all <see cref="IClassMetadata"/> as a <see cref="IDictionary"/> from entityname <see langword="string"/>
/// to metadata object
/// </summary>
/// <returns> A dictionary from <see langword="string"/> an entity name to <see cref="IClassMetadata"/> </returns>
IDictionary<string, IClassMetadata> GetAllClassMetadata();
/// <summary>
/// Get all <c>CollectionMetadata</c> as a <c>IDictionary</c> from role name
/// to metadata object
/// </summary>
/// <returns></returns>
IDictionary<string, ICollectionMetadata> GetAllCollectionMetadata();
/// <summary>
/// Destroy this <c>SessionFactory</c> and release all resources
/// connection pools, etc). It is the responsibility of the application
/// to ensure that there are no open <c>Session</c>s before calling
/// <c>close()</c>.
/// </summary>
void Close();
/// <summary>
/// Evict all entries from the process-level cache. This method occurs outside
/// of any transaction; it performs an immediate "hard" remove, so does not respect
/// any transaction isolation semantics of the usage strategy. Use with care.
/// </summary>
/// <param name="persistentClass"></param>
void Evict(System.Type persistentClass);
/// <summary>
/// Evict an entry from the process-level cache. This method occurs outside
/// of any transaction; it performs an immediate "hard" remove, so does not respect
/// any transaction isolation semantics of the usage strategy. Use with care.
/// </summary>
/// <param name="persistentClass"></param>
/// <param name="id"></param>
void Evict(System.Type persistentClass, object id);
/// <summary>
/// Evict all entries from the second-level cache. This method occurs outside
/// of any transaction; it performs an immediate "hard" remove, so does not respect
/// any transaction isolation semantics of the usage strategy. Use with care.
/// </summary>
void EvictEntity(string entityName);
/// <summary>
/// Evict an entry from the second-level cache. This method occurs outside
/// of any transaction; it performs an immediate "hard" remove, so does not respect
/// any transaction isolation semantics of the usage strategy. Use with care.
/// </summary>
void EvictEntity(string entityName, object id);
/// <summary>
/// Evict all entries from the process-level cache. This method occurs outside
/// of any transaction; it performs an immediate "hard" remove, so does not respect
/// any transaction isolation semantics of the usage strategy. Use with care.
/// </summary>
/// <param name="roleName"></param>
void EvictCollection(string roleName);
/// <summary>
/// Evict an entry from the process-level cache. This method occurs outside
/// of any transaction; it performs an immediate "hard" remove, so does not respect
/// any transaction isolation semantics of the usage strategy. Use with care.
/// </summary>
/// <param name="roleName"></param>
/// <param name="id"></param>
void EvictCollection(string roleName, object id);
/// <summary>
/// Evict any query result sets cached in the default query cache region.
/// </summary>
void EvictQueries();
/// <summary>
/// Evict any query result sets cached in the named query cache region.
/// </summary>
/// <param name="cacheRegion"></param>
void EvictQueries(string cacheRegion);
/// <summary>
/// Obtain the definition of a filter by name.
/// </summary>
/// <param name="filterName">The name of the filter for which to obtain the definition.</param>
/// <return>The filter definition.</return>
FilterDefinition GetFilterDefinition(string filterName);
/// <summary>
/// Obtains the current session.
/// </summary>
/// <remarks>
/// <para>
/// The definition of what exactly "current" means is controlled by the <see cref="NHibernate.Context.ICurrentSessionContext" />
/// implementation configured for use.
/// </para>
/// </remarks>
/// <returns>The current session.</returns>
/// <exception cref="HibernateException">Indicates an issue locating a suitable current session.</exception>
ISession GetCurrentSession();
/// <summary> Get the statistics for this session factory</summary>
IStatistics Statistics { get;}
/// <summary> Was this <see cref="ISessionFactory"/> already closed?</summary>
bool IsClosed { get;}
/// <summary>
/// Obtain a set of the names of all filters defined on this SessionFactory.
/// </summary>
/// <return>The set of filter names.</return>
ICollection<string> DefinedFilterNames { get; }
}
}