Skip to content

Commit a1940b9

Browse files
Merge branch 'master' into 5.0.x
2 parents 4e7fbc7 + 70413b7 commit a1940b9

File tree

86 files changed

+1961
-1144
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

86 files changed

+1961
-1144
lines changed

.editorconfig

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,13 @@ indent_size = 2
2020
indent_style = space
2121
indent_size = 2
2222

23+
[*.csproj]
24+
indent_style = space
25+
indent_size = 2
26+
27+
[*.vbproj]
28+
indent_style = space
29+
indent_size = 2
2330

2431
[*.cshtml]
2532
indent_style = space

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,11 @@ Bug Reports
3838

3939
If you find any bugs, please report them using the [GitHub issue tracker][C1]. A
4040
test-case that demonstrates the issue is usually required. Instructions on providing a test-case
41-
can be found [here][C2].
41+
can be found in [contributing guidelines][C3] or [here][C2].
4242

4343
[C1]: http://github.com/nhibernate/nhibernate-core/issues
44-
[C2]: http://nhibernate.info/blog/2008/10/03/the-best-way-to-solve-nhibernate-bugs-submit-good-unit-test.html
44+
[C2]: http://nhibernate.info/blog/2008/10/04/the-best-way-to-solve-nhibernate-bugs-submit-good-unit-test.html
45+
[C3]: CONTRIBUTING.md
4546

4647
Licenses
4748
--------

Tools/packages.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@
77
<package id="NUnit.Extension.NUnitV2ResultWriter" version="3.6.0" targetFramework="net461" />
88
<package id="NUnit.Extension.TeamCityEventListener" version="1.0.2" targetFramework="net461" />
99
<package id="NUnit.Extension.VSProjectLoader" version="3.6.0" targetFramework="net461" />
10-
<package id="CSharpAsyncGenerator.CommandLine" version="0.6.0" targetFramework="net461" />
10+
<package id="CSharpAsyncGenerator.CommandLine" version="0.6.2" targetFramework="net461" />
1111
<package id="vswhere" version="2.1.4" targetFramework="net461" />
1212
</packages>

doc/reference/modules/configuration.xml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1026,6 +1026,29 @@ var session = sessions.OpenSession(conn);
10261026
</para>
10271027
</entry>
10281028
</row>
1029+
<row>
1030+
<entry>
1031+
<literal>track_session_id</literal>
1032+
</entry>
1033+
<entry>
1034+
Set whether the session id should be tracked in logs or not. When <literal>true</literal>, each
1035+
session will have an unique <literal>Guid</literal> that can be retrieved with
1036+
<literal>ISessionImplementor.SessionId</literal>, otherwise <literal>ISessionImplementor.SessionId</literal>
1037+
will be <literal>Guid.Empty</literal>.
1038+
<para>
1039+
Session id is used for logging purpose and can also be retrieved on the static property
1040+
<literal>NHibernate.Impl.SessionIdLoggingContext.SessionId</literal>, when tracking is enabled.
1041+
</para>
1042+
<para>
1043+
Disabling tracking by setting <literal>track_session_id</literal> to <literal>false</literal>
1044+
increases performances. Default is <literal>true</literal>.
1045+
</para>
1046+
<para>
1047+
<emphasis role="strong">eg.</emphasis>
1048+
<literal>true</literal> | <literal>false</literal>
1049+
</para>
1050+
</entry>
1051+
</row>
10291052
<row>
10301053
<entry>
10311054
<literal>sql_types.keep_datetime</literal>

doc/reference/modules/manipulating_data.xml

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -820,7 +820,7 @@ sess.Lock(pk, LockMode.Upgrade);]]></programlisting>
820820
</orderedlist>
821821

822822
<para>
823-
(An exception is that objects using <literal>native</literal> ID generation are
823+
(An exception is that objects using <literal>identity</literal> ID generation are
824824
inserted when they are saved.)
825825
</para>
826826

@@ -861,6 +861,37 @@ using (ITransaction tx = sess.BeginTransaction())
861861

862862
</sect1>
863863

864+
<sect1 id="manipulatingdata-dirtiness">
865+
<title>Checking dirtiness</title>
866+
867+
<para>
868+
<literal>ISession.IsDirty()</literal> will return whether the session hold any pending
869+
change to flush or not. Be cautious when using this method, its default implementation
870+
may have the following effects:
871+
</para>
872+
873+
<itemizedlist spacing="compact">
874+
<listitem>
875+
<para>
876+
Dirty checks all the loaded entities. NHibernate does not instrument the entities
877+
for being notified of changes done on loaded ones. Instead, it stores their
878+
initial state and compare them to it. If session has loaded a lot of entities,
879+
the dirty checking will have a significant impact.
880+
</para>
881+
</listitem>
882+
<listitem>
883+
<para>
884+
Triggers pending cascade operations. This includes any pending <literal>Save</literal>
885+
of, by example, children added to a collection having the <literal>Save</literal>
886+
cascade enabled. Depending on the entities ID generators (see
887+
<xref linkend="mapping-declaration-id-generator"/>), this may trigger calls to the
888+
database, or even entity insertions if they are using the <literal>identity</literal>
889+
generator.
890+
</para>
891+
</listitem>
892+
</itemizedlist>
893+
</sect1>
894+
864895
<sect1 id="manipulatingdata-endingsession">
865896
<title>Ending a Session</title>
866897

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
//------------------------------------------------------------------------------
2+
// <auto-generated>
3+
// This code was generated by AsyncGenerator.
4+
//
5+
// Changes to this file may cause incorrect behavior and will be lost if
6+
// the code is regenerated.
7+
// </auto-generated>
8+
//------------------------------------------------------------------------------
9+
10+
11+
using System;
12+
using System.Collections;
13+
using NHibernate.Dialect;
14+
using NHibernate.Driver;
15+
using NHibernate.Engine;
16+
using NUnit.Framework;
17+
18+
namespace NHibernate.Test.DriverTest
19+
{
20+
using System.Threading.Tasks;
21+
[TestFixture]
22+
public class OdbcDriverFixtureAsync : TestCase
23+
{
24+
protected override string MappingsAssembly => "NHibernate.Test";
25+
26+
protected override IList Mappings => new[] { "DriverTest.MultiTypeEntity.hbm.xml" };
27+
28+
protected override bool AppliesTo(Dialect.Dialect dialect)
29+
{
30+
return dialect is MsSql2000Dialect;
31+
}
32+
33+
protected override bool AppliesTo(ISessionFactoryImplementor factory)
34+
{
35+
return factory.ConnectionProvider.Driver is OdbcDriver;
36+
}
37+
38+
protected override void OnTearDown()
39+
{
40+
base.OnTearDown();
41+
42+
using (var s = OpenSession())
43+
using (var t = s.BeginTransaction())
44+
{
45+
s.CreateQuery("delete from MultiTypeEntity").ExecuteUpdate();
46+
t.Commit();
47+
}
48+
}
49+
50+
[Test]
51+
public async Task CrudAsync()
52+
{
53+
// Should use default dimension for CRUD op because the mapping does not
54+
// have dimensions specified.
55+
object savedId;
56+
using (var s = OpenSession())
57+
using (var t = s.BeginTransaction())
58+
{
59+
savedId = await (s.SaveAsync(
60+
new MultiTypeEntity
61+
{
62+
StringProp = "a",
63+
StringClob = "a",
64+
BinaryBlob = new byte[] { 1, 2, 3 },
65+
Binary = new byte[] { 4, 5, 6 },
66+
Currency = 123.4m,
67+
Double = 123.5d,
68+
Decimal = 789.5m,
69+
DecimalHighScale = 1234567890.0123456789m
70+
}));
71+
await (t.CommitAsync());
72+
}
73+
74+
using (var s = OpenSession())
75+
using (var t = s.BeginTransaction())
76+
{
77+
var m = await (s.GetAsync<MultiTypeEntity>(savedId));
78+
79+
Assert.That(m.StringProp, Is.EqualTo("a"), "StringProp");
80+
Assert.That(m.StringClob, Is.EqualTo("a"), "StringClob");
81+
Assert.That(m.BinaryBlob, Is.EqualTo(new byte[] { 1, 2, 3 }), "BinaryBlob");
82+
Assert.That(m.Binary, Is.EqualTo(new byte[] { 4, 5, 6 }), "BinaryBlob");
83+
Assert.That(m.Currency, Is.EqualTo(123.4m), "Currency");
84+
Assert.That(m.Double, Is.EqualTo(123.5d).Within(0.0001d), "Double");
85+
Assert.That(m.Decimal, Is.EqualTo(789.5m), "Decimal");
86+
Assert.That(m.DecimalHighScale, Is.EqualTo(1234567890.0123456789m), "DecimalHighScale");
87+
88+
m.StringProp = "b";
89+
m.StringClob = "b";
90+
m.BinaryBlob = new byte[] { 4, 5, 6 };
91+
m.Binary = new byte[] { 7, 8, 9 };
92+
m.Currency = 456.78m;
93+
m.Double = 987.6d;
94+
m.Decimal = 1323456.45m;
95+
m.DecimalHighScale = 9876543210.0123456789m;
96+
await (t.CommitAsync());
97+
}
98+
99+
using (var s = OpenSession())
100+
using (var t = s.BeginTransaction())
101+
{
102+
var m = await (s.LoadAsync<MultiTypeEntity>(savedId));
103+
104+
Assert.That(m.StringProp, Is.EqualTo("b"), "StringProp");
105+
Assert.That(m.StringClob, Is.EqualTo("b"), "StringClob");
106+
Assert.That(m.BinaryBlob, Is.EqualTo(new byte[] { 4, 5, 6 }), "BinaryBlob");
107+
Assert.That(m.Binary, Is.EqualTo(new byte[] { 7, 8, 9 }), "BinaryBlob");
108+
Assert.That(m.Currency, Is.EqualTo(456.78m), "Currency");
109+
Assert.That(m.Double, Is.EqualTo(987.6d).Within(0.0001d), "Double");
110+
Assert.That(m.Decimal, Is.EqualTo(1323456.45m), "Decimal");
111+
Assert.That(m.DecimalHighScale, Is.EqualTo(9876543210.0123456789m), "DecimalHighScale");
112+
113+
await (t.CommitAsync());
114+
}
115+
}
116+
}
117+
}

0 commit comments

Comments
 (0)