Skip to content

Commit 188deef

Browse files
committed
Document difference between .Insert()/.Update and .Generated.Insert()/.Update()
Closes #364 +semver:patch
1 parent 7f26f75 commit 188deef

File tree

10 files changed

+60
-3
lines changed

10 files changed

+60
-3
lines changed

src/FluentNHibernate/Conventions/Inspections/Generated.cs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,26 @@ namespace FluentNHibernate.Conventions.Inspections
22
{
33
public class Generated
44
{
5+
/// <summary>
6+
/// Use the default value.
7+
/// </summary>
58
public static readonly Generated Unset = new Generated("");
9+
10+
/// <summary>
11+
/// The property value as not generated within the database (default).
12+
/// </summary>
613
public static readonly Generated Never = new Generated("never");
14+
15+
/// <summary>
16+
/// The property value as generated on INSERT, but is not regenerated on subsequent updates.
17+
/// <para>NHibernate will immediately issues a SELECT after INSERT to retrieve the generated values.</para>
18+
/// </summary>
719
public static readonly Generated Insert = new Generated("insert");
20+
21+
/// <summary>
22+
/// The property value as generated both on INSERT and on UPDATE.
23+
/// <para>NHibernate will immediately issues a SELECT after INSERT or UPDATE to retrieve the generated values.</para>
24+
/// </summary>
825
public static readonly Generated Always = new Generated("always");
926

1027
private readonly string value;
@@ -16,7 +33,7 @@ private Generated(string value)
1633

1734
public override bool Equals(object obj)
1835
{
19-
if (obj is Generated) return Equals((Generated)obj);
36+
if (obj is Generated) return Equals((Generated) obj);
2037

2138
return base.Equals(obj);
2239
}

src/FluentNHibernate/Conventions/Instances/GeneratedInstance.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace FluentNHibernate.Conventions.Instances
44
{
5+
/// <inheritdoc cref="IGeneratedInstance"/>
56
public class GeneratedInstance : IGeneratedInstance
67
{
78
private readonly Action<string> setter;
@@ -11,16 +12,19 @@ public GeneratedInstance(Action<string> setter)
1112
this.setter = setter;
1213
}
1314

15+
/// <inheritdoc />
1416
public void Never()
1517
{
1618
setter("never");
1719
}
1820

21+
/// <inheritdoc />
1922
public void Insert()
2023
{
2124
setter("insert");
2225
}
2326

27+
/// <inheritdoc />
2428
public void Always()
2529
{
2630
setter("always");
Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,27 @@
1-
using FluentNHibernate.Conventions.Inspections;
2-
31
namespace FluentNHibernate.Conventions.Instances
42
{
3+
/// <summary>
4+
/// Instructs NHibernate to immediately issues a SELECT after INSERT or UPDATE to retrieve the generated values.
5+
/// <para> See https://nhibernate.info/doc/nhibernate-reference/mapping.html#mapping-generated for more information. </para>
6+
/// </summary>
7+
/// <remarks> It is user's responsibility to specify how the columns are generated. </remarks>
58
public interface IGeneratedInstance
69
{
10+
/// <summary>
11+
/// Marks the property value as not generated within the database (default).
12+
/// </summary>
713
void Never();
14+
15+
/// <summary>
16+
/// Marks the property value as generated on INSERT, but is not regenerated on subsequent UPDATEs.
17+
/// <para>NHibernate will immediately issues a SELECT after INSERT to retrieve the generated values.</para>
18+
/// </summary>
819
void Insert();
20+
21+
/// <summary>
22+
/// Marks the property value as generated both on INSERT and on UPDATE.
23+
/// <para>NHibernate will immediately issues a SELECT after INSERT or UPDATE to retrieve the generated values.</para>
24+
/// </summary>
925
void Always();
1026
}
1127
}

src/FluentNHibernate/Conventions/Instances/IInsertInstance.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ namespace FluentNHibernate.Conventions.Instances
22
{
33
public interface IInsertInstance
44
{
5+
/// <summary>
6+
/// Specifies that the mapped columns should be included in or excluded from SQL INSERT statement.
7+
/// </summary>
58
void Insert();
69
}
710
}

src/FluentNHibernate/Conventions/Instances/IPropertyInstance.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ public interface IPropertyInstance
3030
new void UniqueKey(string keyName);
3131
void Column(string columnName);
3232
new void Formula(string formula);
33+
/// <summary>
34+
/// Instructs NHibernate to immediately issues a SELECT after INSERT or UPDATE to retrieve the generated values.
35+
/// <para> See https://nhibernate.info/doc/nhibernate-reference/mapping.html#mapping-generated for more information. </para>
36+
/// </summary>
37+
/// <remarks> It is user's responsibility to specify how the columns are generated. </remarks>
3338
new IGeneratedInstance Generated { get; }
3439
new void OptimisticLock();
3540
new void Length(int length);

src/FluentNHibernate/Conventions/Instances/IReadOnlyInstance.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ namespace FluentNHibernate.Conventions.Instances
22
{
33
public interface IReadOnlyInstance
44
{
5+
/// <summary> Shortcut for setting <c>.Not.Insert().Not.Update()</c>. </summary>
56
void ReadOnly();
67
}
78
}

src/FluentNHibernate/Conventions/Instances/IUpdateInstance.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ namespace FluentNHibernate.Conventions.Instances
22
{
33
public interface IUpdateInstance
44
{
5+
/// Specifies that the mapped columns should be included or excluded in SQL UPDATE statement.
56
void Update();
67
}
78
}

src/FluentNHibernate/Conventions/Instances/IVersionInstance.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ namespace FluentNHibernate.Conventions.Instances
77
public interface IVersionInstance : IVersionInspector
88
{
99
new IAccessInstance Access { get; }
10+
/// <summary>
11+
/// Instructs NHibernate to immediately issues a SELECT after INSERT or UPDATE to retrieve the generated values.
12+
/// <para> See https://nhibernate.info/doc/nhibernate-reference/mapping.html#mapping-generated for more information. </para>
13+
/// </summary>
14+
/// <remarks> It is user's responsibility to specify how the columns are generated. </remarks>
1015
new IGeneratedInstance Generated { get; }
1116
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
1217
IVersionInstance Not { get; }

src/FluentNHibernate/Conventions/Instances/PropertyInstance.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,21 @@ public PropertyInstance(PropertyMapping mapping)
1919
this.mapping = mapping;
2020
}
2121

22+
/// <inheritdoc />
2223
public new void Insert()
2324
{
2425
mapping.Set(x => x.Insert, layer, nextBool);
2526
nextBool = true;
2627
}
2728

29+
/// <inheritdoc />
2830
public new void Update()
2931
{
3032
mapping.Set(x => x.Update, layer, nextBool);
3133
nextBool = true;
3234
}
3335

36+
/// <inheritdoc />
3437
public new void ReadOnly()
3538
{
3639
mapping.Set(x => x.Insert, layer, !nextBool);
@@ -159,6 +162,7 @@ public void Column(string columnName)
159162
mapping.MakeColumnsEmpty(Layer.UserSupplied);
160163
}
161164

165+
/// <inheritdoc />
162166
public new IGeneratedInstance Generated
163167
{
164168
get { return new GeneratedInstance(value => mapping.Set(x => x.Generated, layer, value)); }

src/FluentNHibernate/Conventions/Instances/VersionInstance.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ public VersionInstance(VersionMapping mapping)
2323
get { return new AccessInstance(value => mapping.Set(x => x.Access, layer, value)); }
2424
}
2525

26+
/// <inheritdoc />
2627
public new IGeneratedInstance Generated
2728
{
2829
get { return new GeneratedInstance(value => mapping.Set(x => x.Generated, layer, value)); }

0 commit comments

Comments
 (0)