forked from nhibernate/nhibernate-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathIdentifierProperty.cs
101 lines (92 loc) · 3.13 KB
/
IdentifierProperty.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
using System;
using NHibernate.Engine;
using NHibernate.Id;
using NHibernate.Type;
namespace NHibernate.Tuple
{
/// <summary>
/// Represents a defined entity identifier property within the Hibernate
/// runtime-metamodel.
/// </summary>
/// <remarks>
/// Author: Steve Ebersole
/// </remarks>
[Serializable]
public class IdentifierProperty : Property
{
private readonly bool isVirtual;
private readonly bool embedded;
private readonly IdentifierValue unsavedValue;
private readonly IIdentifierGenerator identifierGenerator;
private readonly bool identifierAssignedByInsert;
private readonly bool hasIdentifierMapper;
/// <summary>
/// Construct a non-virtual identifier property.
/// </summary>
/// <param name="name">The name of the property representing the identifier within
/// its owning entity.</param>
/// <param name="type">The Hibernate Type for the identifier property.</param>
/// <param name="embedded">Is this an embedded identifier.</param>
/// <param name="unsavedValue">The value which, if found as the value on the identifier
/// property, represents new (i.e., un-saved) instances of the owning entity.</param>
/// <param name="identifierGenerator">The generator to use for id value generation.</param>
public IdentifierProperty(
String name,
IType type,
bool embedded,
IdentifierValue unsavedValue,
IIdentifierGenerator identifierGenerator)
: base(name, type)
{
isVirtual = false;
this.embedded = embedded;
hasIdentifierMapper = false;
this.unsavedValue = unsavedValue;
this.identifierGenerator = identifierGenerator;
identifierAssignedByInsert = identifierGenerator is IPostInsertIdentifierGenerator;
}
/// <summary>
/// Construct a virtual IdentifierProperty.
/// </summary>
/// <param name="type">The Hibernate Type for the identifier property.</param>
/// <param name="embedded">Is this an embedded identifier.</param>
/// <param name="unsavedValue">The value which, if found as the value on the identifier
/// property, represents new (i.e., un-saved) instances of the owning entity.</param>
/// <param name="identifierGenerator">The generator to use for id value generation.</param>
/// <param name="hasIdentifierMapper"></param>
public IdentifierProperty(IType type, bool embedded, bool hasIdentifierMapper, IdentifierValue unsavedValue, IIdentifierGenerator identifierGenerator)
: base(null, type)
{
isVirtual = true;
this.embedded = embedded;
this.hasIdentifierMapper = hasIdentifierMapper;
this.unsavedValue = unsavedValue;
this.identifierGenerator = identifierGenerator;
identifierAssignedByInsert = identifierGenerator is IPostInsertIdentifierGenerator;
}
public bool IsVirtual
{
get { return isVirtual; }
}
public bool IsEmbedded
{
get { return embedded; }
}
public IdentifierValue UnsavedValue
{
get { return unsavedValue; }
}
public IIdentifierGenerator IdentifierGenerator
{
get { return identifierGenerator; }
}
public bool IsIdentifierAssignedByInsert
{
get { return identifierAssignedByInsert; }
}
public bool HasIdentifierMapper
{
get { return hasIdentifierMapper; }
}
}
}