Skip to content

Commit b7caea0

Browse files
Merge 5.4.1 into master
2 parents ab5eb9d + fe7b6f0 commit b7caea0

File tree

20 files changed

+684
-20
lines changed

20 files changed

+684
-20
lines changed

doc/reference/modules/basic_mapping.xml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2385,6 +2385,7 @@
23852385
<area id="onetoone9" coords="10 60"/>
23862386
<area id="onetoone10" coords="11 60"/>
23872387
<area id="onetoone11" coords="12 60"/>
2388+
<area id="onetoone12" coords="13 60"/>
23882389
</areaspec>
23892390
<programlisting><![CDATA[<one-to-one
23902391
name="propertyName"
@@ -2398,6 +2399,7 @@
23982399
formula="any SQL expression"
23992400
entity-name="entityName"
24002401
foreign-key="foreignKeyName"
2402+
optimistic-lock="true|false"
24012403
/>]]></programlisting>
24022404
<calloutlist>
24032405
<callout arearefs="onetoone1">
@@ -2471,12 +2473,20 @@
24712473
<literal>entity-name</literal> (optional): The entity name of the associated class.
24722474
</para>
24732475
</callout>
2474-
<callout arearefs="manytoone11">
2476+
<callout arearefs="onetoone11">
24752477
<para>
24762478
<literal>foreign-key</literal> (optional): Specifies the name of the foreign key
24772479
constraint for DDL generation.
24782480
</para>
24792481
</callout>
2482+
<callout arearefs="onetoone12">
2483+
<para>
2484+
<literal>optimistic-lock</literal> (optional - defaults to <literal>true</literal>):
2485+
Specifies that updates to this property do or do not require acquisition of the
2486+
optimistic lock. In other words, determines if a version increment should occur when
2487+
this property is dirty.
2488+
</para>
2489+
</callout>
24802490
</calloutlist>
24812491
</programlistingco>
24822492

doc/reference/modules/configuration.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1728,7 +1728,7 @@ in the parameter binding.</programlisting>
17281728
Use the assembly qualified class name of a custom <literal>IObjectsFactory</literal>
17291729
implementation.
17301730
</para>
1731-
<programlisting><![CDATA[<bytecode-provider
1731+
<programlisting><![CDATA[<objects-factory
17321732
type="className" />]]></programlisting>
17331733
<para>
17341734
You can also set this property by code by setting

releasenotes.txt

Lines changed: 49 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,25 @@
1-
Build 5.4.0
1+
Build 5.4.1
2+
=============================
3+
4+
Release notes - NHibernate - Version 5.4.1
5+
6+
4 issues were resolved in this release.
7+
8+
** Bug
9+
10+
* #3216 Enable one-to-one optimistic lock handling in mapping
11+
* #3215 Count(Distinct ...) does not work
12+
* #3203 Fix a wrong example in configuration documentation
13+
14+
** Task
15+
16+
* #3232 Release 5.4.1
17+
18+
As part of releasing 5.4.1, a missing 5.4.0 possible breaking change has been added, about
19+
one-to-one associations and optimistic locking. See 5.4.0 possible breaking changes.
20+
21+
22+
Build 5.4.0
223
=============================
324

425
Release notes - NHibernate - Version 5.4.0
@@ -12,6 +33,8 @@ Release notes - NHibernate - Version 5.4.0
1233
* 201 issues were resolved in this release.
1334

1435
##### Possible Breaking Changes #####
36+
* One-to-one changes does now trigger a version increment, consistently with the default behavior of other kinds of
37+
associations. See #3204.
1538
* Linq and criteria queries on unmapped entities will throw instead of returning an empty result list. See #1106, #1095.
1639
* The second level cache UpdateTimestampsCache does not use locks anymore. This may slightly increase the number of cases
1740
where stale data is returned by the query cache. See #2742.
@@ -186,6 +209,24 @@ Release notes - NHibernate - Version 5.4.0
186209
* #2242 Test case for NH-3972 - SQL error when selecting a column of a subclass when sibling classes have a column of the same name
187210

188211

212+
Build 5.3.15
213+
=============================
214+
215+
Release notes - NHibernate - Version 5.3.15
216+
217+
4 issues were resolved in this release.
218+
219+
** Bug
220+
221+
* #3218 Failure of contains subquery with parameter
222+
* #3187 Fix mixing implied implicit and left joins in HQL for v5.3
223+
224+
** Task
225+
226+
* #3225 Release 5.3.15
227+
* #3222 Automatically generate async code on pull requests for 5.3
228+
229+
189230
Build 5.3.14
190231
=============================
191232

@@ -195,8 +236,8 @@ Release notes - NHibernate - Version 5.3.14
195236

196237
** Bug
197238

198-
#3169 InvalidOperationException: This transformer is not initialized by Cached Query
199-
#3164 Fetching a lazy loaded component regression
239+
* #3169 InvalidOperationException: This transformer is not initialized by Cached Query
240+
* #3164 Fetching a lazy loaded component regression
200241

201242
** Task
202243

@@ -212,14 +253,14 @@ Release notes - NHibernate - Version 5.3.13
212253

213254
** Bug
214255

215-
#3134 ManyToMany - Tries to select not existing column in Mapping Table
216-
#3113 Join fails on Oracle9Dialect
217-
#3030 Memory leak named parameter holds entity references
256+
* #3134 ManyToMany - Tries to select not existing column in Mapping Table
257+
* #3113 Join fails on Oracle9Dialect
258+
* #3030 Memory leak named parameter holds entity references
218259

219260
** Improvement
220261

221-
#3120 Guards against use of a disposed session factory
222-
#2994 Npgsql 6 is not compatible
262+
* #3120 Guards against use of a disposed session factory
263+
* #2994 Npgsql 6 is not compatible
223264

224265
** Task
225266

src/NHibernate.Test/Async/Hql/EntityJoinHqlTest.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,13 +359,17 @@ from x2 in session.Query<NullableOwner>()
359359
var withNullOrValidList = await (session.Query<NullableOwner>().Where(x => x.ManyToOne.Id == validManyToOne.Id || x.ManyToOne == null).ToListAsync());
360360
var withNullOrValidList2 = await (session.Query<NullableOwner>().Where(x => x.ManyToOne == null || x.ManyToOne.Id == validManyToOne.Id).ToListAsync());
361361

362+
//GH-3185
363+
var mixImplicitAndLeftJoinList = await (session.Query<NullableOwner>().Where(x => x.ManyToOne.Id == validManyToOne.Id && x.OneToOne == null).ToListAsync());
364+
362365
Assert.That(fullList.Count, Is.EqualTo(2));
363366
Assert.That(withValidManyToOneList.Count, Is.EqualTo(0));
364367
Assert.That(withValidManyToOneList2.Count, Is.EqualTo(0));
365368
Assert.That(withNullManyToOneList.Count, Is.EqualTo(2));
366369
Assert.That(withNullManyToOneJoinedList.Count, Is.EqualTo(2));
367370
Assert.That(withNullOrValidList.Count, Is.EqualTo(2));
368371
Assert.That(withNullOrValidList2.Count, Is.EqualTo(2));
372+
Assert.That(mixImplicitAndLeftJoinList.Count, Is.EqualTo(1));
369373
}
370374
}
371375

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
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 NHibernate.Cfg.MappingSchema;
13+
using NHibernate.Mapping.ByCode;
14+
using NUnit.Framework;
15+
16+
namespace NHibernate.Test.NHSpecificTest.GH3204
17+
{
18+
using System.Threading.Tasks;
19+
[TestFixture(true)]
20+
[TestFixture(false)]
21+
[TestFixture(null)]
22+
public class OneToOneOptimisticLockFixtureAsync : TestCaseMappingByCode
23+
{
24+
private readonly bool? _optimisticLock;
25+
private Guid _id;
26+
27+
public OneToOneOptimisticLockFixtureAsync(bool? optimisticLock)
28+
{
29+
_optimisticLock = optimisticLock;
30+
}
31+
32+
protected override HbmMapping GetMappings()
33+
{
34+
var mapper = new ModelMapper();
35+
mapper.Class<Entity>(
36+
rc =>
37+
{
38+
rc.Id(x => x.Id, m => m.Generator(Generators.GuidComb));
39+
rc.Property(x => x.Name);
40+
rc.Version(x => x.Version, m => { });
41+
rc.OneToOne(
42+
x => x.OneToOne,
43+
m =>
44+
{
45+
m.PropertyReference(x => x.Parent);
46+
m.ForeignKey("none");
47+
m.Cascade(Mapping.ByCode.Cascade.All);
48+
if (_optimisticLock.HasValue)
49+
m.OptimisticLock(_optimisticLock.Value);
50+
});
51+
});
52+
53+
mapper.Class<Child>(
54+
rc =>
55+
{
56+
rc.Id(x => x.Id, m => m.Generator(Generators.GuidComb));
57+
rc.Property(x => x.Name);
58+
rc.ManyToOne(
59+
x => x.Parent,
60+
m =>
61+
{
62+
m.Unique(true);
63+
m.ForeignKey("none");
64+
});
65+
});
66+
67+
return mapper.CompileMappingForAllExplicitlyAddedEntities();
68+
}
69+
70+
protected override void OnSetUp()
71+
{
72+
using (var session = OpenSession())
73+
using (var transaction = session.BeginTransaction())
74+
{
75+
var e1 = new Entity { Name = "Bob" };
76+
session.Save(e1);
77+
transaction.Commit();
78+
_id = e1.Id;
79+
}
80+
}
81+
82+
protected override void OnTearDown()
83+
{
84+
using (var session = OpenSession())
85+
using (var transaction = session.BeginTransaction())
86+
{
87+
session.CreateQuery("delete from System.Object").ExecuteUpdate();
88+
89+
transaction.Commit();
90+
}
91+
}
92+
93+
[Test]
94+
public async Task GetAsync()
95+
{
96+
using (var session = OpenSession())
97+
using (var transaction = session.BeginTransaction())
98+
{
99+
var result = await (session.GetAsync<Entity>(_id));
100+
101+
var child = new Child() { Parent = result };
102+
result.OneToOne = child;
103+
var oldVersion = result.Version;
104+
await (transaction.CommitAsync());
105+
session.Clear();
106+
107+
Assert.That(
108+
(await (session.GetAsync<Entity>(_id))).Version,
109+
Is.EqualTo(_optimisticLock.GetValueOrDefault(true) ? oldVersion + 1 : oldVersion));
110+
}
111+
}
112+
}
113+
}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
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 NHibernate.Cfg;
12+
using NHibernate.Cfg.MappingSchema;
13+
using NHibernate.Mapping.ByCode;
14+
using NUnit.Framework;
15+
16+
namespace NHibernate.Test.NHSpecificTest.GH3215
17+
{
18+
using System.Threading.Tasks;
19+
[TestFixture]
20+
public class ByCodeFixtureAsync : TestCaseMappingByCode
21+
{
22+
protected override HbmMapping GetMappings()
23+
{
24+
var mapper = new ModelMapper();
25+
26+
mapper.Class<Member>(rc =>
27+
{
28+
rc.Id(x => x.Code);
29+
rc.Property(x => x.Name);
30+
rc.Property(x => x.Date);
31+
});
32+
33+
mapper.Class<Request>(rc =>
34+
{
35+
rc.Id(x => x.Id, m => m.Generator(Generators.GuidComb));
36+
rc.ManyToOne(x => x.Member);
37+
});
38+
return mapper.CompileMappingForAllExplicitlyAddedEntities();
39+
}
40+
41+
protected override bool AppliesTo(Dialect.Dialect dialect)
42+
{
43+
return TestDialect.SupportsCountDistinct;
44+
}
45+
46+
protected override void Configure(Configuration configuration)
47+
{
48+
base.Configure(configuration);
49+
configuration.SetProperty(Environment.Hbm2ddlKeyWords, "auto-quote");
50+
}
51+
52+
[Test]
53+
public async Task CountDistinctWithReservedWordsAsync()
54+
{
55+
using (var session = OpenSession())
56+
{
57+
var hql = "select Count(DISTINCT r.Member.id), Count(DISTINCT Date(r.Member.Date)) from Request r";
58+
var result = await (session.CreateQuery(hql).ListAsync());
59+
60+
Assert.That(result, Has.Count.EqualTo(1));
61+
}
62+
}
63+
}
64+
}

0 commit comments

Comments
 (0)