forked from nhibernate/nhibernate-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRootClass.cs
320 lines (293 loc) · 8.31 KB
/
RootClass.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
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
using System;
using System.Collections;
using log4net;
using NHibernate.Cache;
using NHibernate.Persister;
namespace NHibernate.Mapping
{
/// <summary>
/// Declaration of a System.Type by using the <c><class></c> element.
/// </summary>
/// <remarks>
/// <p>The <c><class></c> element has the following attributes available:</p>
/// <list type="table">
/// <listheader>
/// <term>Attribute</term>
/// <description>Possible Values</description>
/// </listheader>
/// <item>
/// <term>name</term>
/// <description>The fully qualified TypeName so it can be loaded by Reflection</description>
/// </item>
/// <item>
/// <term>table</term>
/// <description>The name of its database table.</description>
/// </item>
/// <item>
/// <term>discriminator-value</term>
/// <description>
/// (optional - defaults to the FullClassName) A value that distinguishes individual
/// subclasses, used for polymorphic behavior.
/// </description>
/// </item>
/// <item>
/// <term>mutable</term>
/// <description>
/// (optional - defaults to <c>true</c>) Specifies that instances of the class
/// are (not) mutable.
/// </description>
/// </item>
/// <item>
/// <term>schema</term>
/// <description>(optional) Override the schema name specified by the root <c><hibernate-mapping></c> element.</description>
/// </item>
/// <item>
/// <term>proxy</term>
/// <description>
/// (optional) Specifies an interface to use for lazy initializing proxies.
/// You may specify the name of the class itself.
/// (TODO: update once Proxies are implemented)
/// </description>
/// </item>
/// <item>
/// <term>dynamic-update</term>
/// <description>
/// (optional - defaults to <c>false</c>) Specifies the <c>UPDATE</c> SQL should
/// be generated at runtime and contain only those columns whose values have changed.
/// </description>
/// </item>
/// <item>
/// <term>dynamic-insert</term>
/// <description>
/// (optional - defaults to <c>false</c>) Specifies the <c>INSERT</c> SQL should
/// be generated at runtime and contain only those columns whose values are not null.
/// </description>
/// </item>
/// <item>
/// <term>polymorphism</term>
/// <description>
/// (optional, defaults to <c>implicit</c>) Determines whether implicit or explicit
/// query polymorphism is used.
/// </description>
/// </item>
/// <item>
/// <term>where</term>
/// <description>
/// (optional) Specify an arbitrary SQL <c>WHERE</c> condition to be used
/// when retrieving objects of this class.
/// </description>
/// </item>
/// <item>
/// <term>persister</term>
/// <description>(optional) Specifies a custom <see cref="IClassPersister"/>.</description>
/// </item>
/// </list>
/// </remarks>
public class RootClass : PersistentClass
{
private static readonly ILog log = LogManager.GetLogger( typeof( RootClass ) );
/// <summary></summary>
public const string DefaultIdentifierColumnName = "id";
/// <summary></summary>
public const string DefaultDiscriminatorColumnName = "class";
private Property identifierProperty;
private Value identifier;
private Property version;
private bool polymorphic;
private ICacheConcurrencyStrategy cache;
private Value discriminator;
private bool mutable;
private bool embeddedIdentifier = false;
private bool explicitPolymorphism;
private System.Type persister;
private bool forceDiscriminator;
private string where;
/// <summary></summary>
public bool Polymorphic
{
set { polymorphic = value; }
}
/// <summary></summary>
public override Property IdentifierProperty
{
get { return identifierProperty; }
set { identifierProperty = value; }
}
/// <summary></summary>
public override Value Identifier
{
get { return identifier; }
set { identifier = value; }
}
/// <summary></summary>
public override bool HasIdentifierProperty
{
get { return identifierProperty != null; }
}
/// <summary></summary>
public override Value Discriminator
{
get { return discriminator; }
set { discriminator = value; }
}
/// <summary></summary>
public override bool IsInherited
{
get { return false; }
}
/// <summary>
/// Indicates if the object has subclasses
/// </summary>
/// <remarks>
/// This value is set to True when a subclass is added and should not be set
/// through any other method - so no setter is declared for this property.
/// </remarks>
public override bool IsPolymorphic
{
get { return polymorphic; }
}
/// <summary></summary>
public override RootClass RootClazz
{
get { return this; }
}
/// <summary></summary>
public override ICollection PropertyClosureCollection
{
get { return PropertyCollection; }
}
/// <summary>
/// Returns all of the Tables the Root class covers.
/// </summary>
/// <remarks>
/// The RootClass should only have one item in the Collection - the Table that it comes from.
/// </remarks>
public override ICollection TableClosureCollection
{
get
{
ArrayList retVal = new ArrayList();
retVal.Add( Table );
return retVal;
}
}
/// <summary>
///
/// </summary>
/// <param name="subclass"></param>
public override void AddSubclass( Subclass subclass )
{
base.AddSubclass( subclass );
polymorphic = true;
}
/// <summary></summary>
public override bool IsExplicitPolymorphism
{
get { return explicitPolymorphism; }
set { explicitPolymorphism = value; }
}
/// <summary>
/// Gets or Sets the <see cref="Property"/> to use as the Version Property
/// </summary>
/// <value>The <see cref="Property"/> to use for Versioning.</value>
/// <remarks>
/// <para>
/// The <version> element is optional and indicates that the table contains versioned data.
/// This is particularly useful if you plan to use long transactions (see below).
/// </para>
/// <para>
/// <list type="table">
/// <listheader>
/// <term>Attribute</term>
/// <description>Possible Values</description>
/// </listheader>
/// <item>
/// <term>column</term>
/// <description>
/// The name of the <c>column</c> holding the version number.
/// Defaults to the Property name.
/// </description>
/// </item>
/// <item>
/// <term>name</term>
/// <description>The name of the Property in the Persistent Class.</description>
/// </item>
/// <item>
/// <term>type</term>
/// <description>
/// The <see cref="Type.IType"/> of the Property. Defaults to an <see cref="Type.Int32Type"/>. It
/// be any <see cref="Type.IVersionType"/>.
/// </description>
/// </item>
/// </list>
/// </para>
/// </remarks>
public override Property Version
{
get { return version; }
set { version = value; }
}
/// <summary>
/// Gets a value indicating if the <see cref="PersistentClass" /> is versioned
/// by NHibernate.
/// </summary>
/// <value><c>true</c> if there is a version property.</value>
public override bool IsVersioned
{
get { return version != null; }
}
/// <summary></summary>
public override ICacheConcurrencyStrategy Cache
{
get { return cache; }
set { cache = value; }
}
/// <summary></summary>
public override bool IsMutable
{
get { return mutable; }
set { mutable = value; }
}
/// <summary></summary>
public override bool HasEmbeddedIdentifier
{
get { return embeddedIdentifier; }
set { embeddedIdentifier = value; }
}
/// <summary></summary>
public override System.Type Persister
{
get { return persister; }
set { persister = value; }
}
/// <summary></summary>
public override Table RootTable
{
get { return Table; }
}
/// <summary></summary>
public override PersistentClass Superclass
{
get { return null; }
set { throw new InvalidOperationException( "Can not set the Superclass on a RootClass." ); }
}
/// <summary></summary>
public override Value Key
{
get { return Identifier; }
set { throw new InvalidOperationException(); }
}
/// <summary></summary>
public override bool IsForceDiscriminator
{
get { return forceDiscriminator; }
set { this.forceDiscriminator = value; }
}
/// <summary></summary>
public override string Where
{
get { return where; }
set { where = value; }
}
}
}