-
Notifications
You must be signed in to change notification settings - Fork 934
/
Copy pathIStatelessSession.cs
185 lines (160 loc) · 7.33 KB
/
IStatelessSession.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
using System;
using System.Data;
namespace NHibernate
{
/// <summary>
/// A command-oriented API for performing bulk operations against a database.
/// </summary>
/// <remarks>
/// A stateless session does not implement a first-level cache nor
/// interact with any second-level cache, nor does it implement
/// transactional write-behind or automatic dirty checking, nor do
/// operations cascade to associated instances. Collections are
/// ignored by a stateless session. Operations performed via a
/// stateless session bypass Hibernate's event model and
/// interceptors. Stateless sessions are vulnerable to data
/// aliasing effects, due to the lack of a first-level cache.
/// <para/>
/// For certain kinds of transactions, a stateless session may
/// perform slightly faster than a stateful session.
/// </remarks>
public interface IStatelessSession : IDisposable
{
/// <summary> Get the current Hibernate transaction.</summary>
ITransaction Transaction { get;}
/// <summary> Close the stateless session and release the ADO.NET connection.</summary>
void Close();
/// <summary> Insert a entity.</summary>
/// <param name="entity">A new transient instance </param>
/// <returns> the identifier of the instance </returns>
object Insert(object entity);
/// <summary> Insert a row. </summary>
/// <param name="entityName">The entityName for the entity to be inserted </param>
/// <param name="entity">a new transient instance </param>
/// <returns> the identifier of the instance </returns>
object Insert(string entityName, object entity);
/// <summary> Update a entity.</summary>
/// <param name="entity">a detached entity instance </param>
void Update(object entity);
/// <summary>Update a entity.</summary>
/// <param name="entityName">The entityName for the entity to be updated </param>
/// <param name="entity">a detached entity instance </param>
void Update(string entityName, object entity);
/// <summary> Delete a entity. </summary>
/// <param name="entity">a detached entity instance </param>
void Delete(object entity);
/// <summary> Delete a entity. </summary>
/// <param name="entityName">The entityName for the entity to be deleted </param>
/// <param name="entity">a detached entity instance </param>
void Delete(string entityName, object entity);
/// <summary> Retrieve a entity. </summary>
/// <returns> a detached entity instance </returns>
object Get(string entityName, object id);
/// <summary> Retrieve a entity.
///
/// </summary>
/// <returns> a detached entity instance
/// </returns>
T Get<T>(object id);
/// <summary>
/// Retrieve a entity, obtaining the specified lock mode.
/// </summary>
/// <returns> a detached entity instance </returns>
object Get(string entityName, object id, LockMode lockMode);
/// <summary>
/// Retrieve a entity, obtaining the specified lock mode.
/// </summary>
/// <returns> a detached entity instance </returns>
T Get<T>(object id, LockMode lockMode);
/// <summary>
/// Refresh the entity instance state from the database.
/// </summary>
/// <param name="entity">The entity to be refreshed. </param>
void Refresh(object entity);
/// <summary>
/// Refresh the entity instance state from the database.
/// </summary>
/// <param name="entityName">The entityName for the entity to be refreshed. </param>
/// <param name="entity">The entity to be refreshed.</param>
void Refresh(string entityName, object entity);
/// <summary>
/// Refresh the entity instance state from the database.
/// </summary>
/// <param name="entity">The entity to be refreshed. </param>
/// <param name="lockMode">The LockMode to be applied.</param>
void Refresh(object entity, LockMode lockMode);
/// <summary>
/// Refresh the entity instance state from the database.
/// </summary>
/// <param name="entityName">The entityName for the entity to be refreshed. </param>
/// <param name="entity">The entity to be refreshed. </param>
/// <param name="lockMode">The LockMode to be applied. </param>
void Refresh(string entityName, object entity, LockMode lockMode);
/// <summary>
/// Create a new instance of <tt>Query</tt> for the given HQL query string.
/// </summary>
/// <remarks>Entities returned by the query are detached.</remarks>
IQuery CreateQuery(string queryString);
/// <summary>
/// Obtain an instance of <see cref="IQuery"/> for a named query string defined in
/// the mapping file.
/// </summary>
/// <remarks>
/// The query can be either in <c>HQL</c> or <c>SQL</c> format.
/// Entities returned by the query are detached.
/// </remarks>
IQuery GetNamedQuery(string queryName);
/// <summary>
/// Create a new <see cref="ICriteria"/> instance, for the given entity class,
/// or a superclass of an entity class.
/// </summary>
/// <typeparam name="T">A class, which is persistent, or has persistent subclasses</typeparam>
/// <returns> The <see cref="ICriteria"/>. </returns>
/// <remarks>Entities returned by the query are detached.</remarks>
ICriteria CreateCriteria<T>();
/// <summary>
/// Create a new <see cref="ICriteria"/> instance, for the given entity class,
/// or a superclass of an entity class, with the given alias.
/// </summary>
/// <typeparam name="T">A class, which is persistent, or has persistent subclasses</typeparam>
/// <param name="alias">The alias of the entity</param>
/// <returns> The <see cref="ICriteria"/>. </returns>
/// <remarks>Entities returned by the query are detached.</remarks>
ICriteria CreateCriteria<T>(string alias);
/// <summary>
/// Create a new <see cref="ICriteria"/> instance, for the given entity name.
/// </summary>
/// <param name="entityName">The entity name. </param>
/// <returns> The <see cref="ICriteria"/>. </returns>
/// <remarks>Entities returned by the query are detached.</remarks>
ICriteria CreateCriteria(string entityName);
/// <summary>
/// Create a new <see cref="ICriteria"/> instance, for the given entity name,
/// with the given alias.
/// </summary>
/// <param name="entityName">The entity name. </param>
/// <param name="alias">The alias of the entity</param>
/// <returns> The <see cref="ICriteria"/>. </returns>
/// <remarks>Entities returned by the query are detached.</remarks>
ICriteria CreateCriteria(string entityName, string alias);
/// <summary>
/// Create a new instance of <see cref="ISQLQuery"/> for the given SQL query string.
/// Entities returned by the query are detached.
/// </summary>
/// <param name="queryString">a SQL query </param>
/// <returns> The <see cref="ISQLQuery"/> </returns>
ISQLQuery CreateSQLQuery(string queryString);
/// <summary> Begin a NHibernate transaction.</summary>
ITransaction BeginTransaction();
/// <summary>
/// Returns the current ADO.NET connection associated with this instance.
/// </summary>
/// <remarks>
/// If the session is using aggressive connection release (as in a
/// CMT environment), it is the application's responsibility to
/// close the connection returned by this call. Otherwise, the
/// application should not close the connection.
/// </remarks>
IDbConnection Connection { get; }
}
}