Skip to content

Commit a390e6d

Browse files
Merge 5.4.3 in master
2 parents 4d29463 + b8d9abd commit a390e6d

Some content is hidden

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

49 files changed

+1761
-44
lines changed

.github/renovate.json

+1-3
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,7 @@
1515
],
1616
"packageRules": [
1717
{
18-
"matchPackagePrefixes": [
19-
"NUnit"
20-
],
18+
"matchSourceUrls": ["https://github.com/nunit/nunit"],
2119
"groupName": "NUnit"
2220
},
2321
{

releasenotes.txt

+62-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,29 @@
1-
Build 5.4.2
1+
Build 5.4.3
2+
=============================
3+
4+
Release notes - NHibernate - Version 5.4.3
5+
6+
11 issues were resolved in this release.
7+
8+
** Bug
9+
10+
* #3317 Issue with components list lazy loading with not lazy association
11+
* #3307 IsDirty performance hit since 5.4.0
12+
* #3295 C# 8/11 Static interface members support
13+
* #3291 Npgsql 6+ issues with null DateTime parameter types
14+
* #3290 Incorrect fetch of Many-to-Many relation
15+
* #3289 Fetching lazy loaded component causes n + 1 query when querying a subclass abstraction
16+
* #3288 NullReferenceException is thrown when using Fetch
17+
18+
** Task
19+
20+
* #3349 Release 5.4.3
21+
* #3348 Merge 5.3.18 in 5.4.x
22+
* #3318 Merge 5.3.17 in 5.4.x
23+
* #3302 Upgrade NUnit3TestAdapter to fix "Unknown framework version 7.0"
24+
25+
26+
Build 5.4.2
227
=============================
328

429
Release notes - NHibernate - Version 5.4.2
@@ -234,6 +259,42 @@ Release notes - NHibernate - Version 5.4.0
234259
* #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
235260

236261

262+
Build 5.3.18
263+
=============================
264+
265+
Release notes - NHibernate - Version 5.3.18
266+
267+
3 issues were resolved in this release.
268+
269+
** Bug
270+
271+
* #3333 Lazy property with nosetter accessor remains uninitialized
272+
* #3330 Linq with FetchLazyProperties() resets lazy property changes
273+
274+
** Task
275+
276+
* #3346 Release 5.3.18
277+
278+
279+
Build 5.3.17
280+
=============================
281+
282+
Release notes - NHibernate - Version 5.3.17
283+
284+
5 issues were resolved in this release.
285+
286+
** Bug
287+
288+
* #3306 Invalid SQL when referencing nullable entity in correlated subquery
289+
* #3304 Fix SetSnapShot CopyTo variance failure
290+
* #3294 Undefined join type failure with cross joins and Informix
291+
292+
** Task
293+
294+
* #3315 Release 5.3.17
295+
* #3300 Backport handling of null DateTime parameters in Npgsql 6+
296+
297+
237298
Build 5.3.16
238299
=============================
239300

src/NHibernate.Test.VisualBasic/NHibernate.Test.VisualBasic.vbproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.0.0" />
2929
<PackageReference Include="Microsoft.VisualBasic" Version="10.3.0" />
3030
<PackageReference Include="NUnit" Version="3.13.2" />
31-
<PackageReference Include="NUnit3TestAdapter" Version="4.2.1" />
31+
<PackageReference Include="NUnit3TestAdapter" Version="4.4.2" />
3232
</ItemGroup>
3333
<ItemGroup Condition="'$(TargetFramework)' == 'net6.0'">
3434
<PackageReference Include="NUnitLite" Version="3.13.2" />

src/NHibernate.Test/Async/FetchLazyProperties/FetchLazyPropertiesFixture.cs

+39
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,45 @@ public async Task TestLinqFetchAllPropertiesAsync()
276276
AssertFetchAllProperties(person);
277277
}
278278

279+
[TestCase(true)]
280+
[TestCase(false)]
281+
public async Task TestLinqFetchAllProperties_WhenLazyPropertyChangedAsync(bool initLazyPropertyFetchGroup)
282+
{
283+
Person person;
284+
using (var s = OpenSession())
285+
{
286+
person = await (s.GetAsync<Person>(1));
287+
if (initLazyPropertyFetchGroup)
288+
CollectionAssert.AreEqual(new byte[] { 0 }, person.Image);
289+
290+
person.Image = new byte[] { 1, 2, 3 };
291+
292+
var allPersons = await (s.Query<Person>().FetchLazyProperties().ToListAsync());
293+
// After execute FetchLazyProperties(), I expected to see that the person.Image would be { 1, 2, 3 }.
294+
// Because I changed this person.Image manually, I didn't want to lose those changes.
295+
// But test failed. Оld value returned { 0 }.
296+
CollectionAssert.AreEqual(new byte[] { 1, 2, 3 }, person.Image);
297+
}
298+
}
299+
300+
[TestCase(true)]
301+
[TestCase(false)]
302+
public async Task TestLinqFetchProperty_WhenLazyPropertyChangedAsync(bool initLazyPropertyFetchGroup)
303+
{
304+
Person person;
305+
using (var s = OpenSession())
306+
{
307+
person = await (s.GetAsync<Person>(1));
308+
if (initLazyPropertyFetchGroup)
309+
CollectionAssert.AreEqual(new byte[] { 0 }, person.Image);
310+
311+
person.Image = new byte[] { 1, 2, 3 };
312+
313+
var allPersons = await (s.Query<Person>().Fetch(x => x.Image).ToListAsync());
314+
CollectionAssert.AreEqual(new byte[] { 1, 2, 3 }, person.Image);
315+
}
316+
}
317+
279318
private static void AssertFetchAllProperties(Person person)
280319
{
281320
Assert.That(person, Is.Not.Null);

src/NHibernate.Test/Async/LazyProperty/LazyPropertyFixture.cs

+55-1
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@
1313
using System.Linq;
1414
using NHibernate.Cfg;
1515
using NHibernate.Intercept;
16+
using NHibernate.Linq;
1617
using NHibernate.Tuple.Entity;
1718
using NUnit.Framework;
1819
using NUnit.Framework.Constraints;
19-
using NHibernate.Linq;
2020

2121
namespace NHibernate.Test.LazyProperty
2222
{
@@ -67,6 +67,7 @@ protected override void OnSetUp()
6767
Id = 1,
6868
ALotOfText = "a lot of text ...",
6969
Image = new byte[10],
70+
NoSetterImage = new byte[10],
7071
FieldInterceptor = "Why not that name?"
7172
});
7273
tx.Commit();
@@ -391,5 +392,58 @@ public async Task CanMergeTransientWithLazyPropertyInCollectionAsync()
391392
Assert.That(book.Words.First().Content, Is.EqualTo(new byte[1] { 0 }));
392393
}
393394
}
395+
396+
[Test(Description = "GH-3333")]
397+
public async Task GetLazyPropertyWithNoSetterAccessor_PropertyShouldBeInitializedAsync()
398+
{
399+
using (ISession s = OpenSession())
400+
{
401+
var book = await (s.GetAsync<Book>(1));
402+
var image = book.NoSetterImage;
403+
// Fails. Property remains uninitialized after it has been accessed.
404+
Assert.That(NHibernateUtil.IsPropertyInitialized(book, "NoSetterImage"), Is.True);
405+
}
406+
}
407+
408+
[Test(Description = "GH-3333")]
409+
public async Task GetLazyPropertyWithNoSetterAccessorTwice_ResultsAreSameObjectAsync()
410+
{
411+
using (ISession s = OpenSession())
412+
{
413+
var book = await (s.GetAsync<Book>(1));
414+
var image = book.NoSetterImage;
415+
var sameImage = book.NoSetterImage;
416+
// Fails. Each call to a property getter returns a new object.
417+
Assert.That(ReferenceEquals(image, sameImage), Is.True);
418+
}
419+
}
420+
421+
[Test]
422+
public async Task CanSetValueForLazyPropertyNoSetterAsync()
423+
{
424+
Book book;
425+
using (ISession s = OpenSession())
426+
{
427+
book = await (s.GetAsync<Book>(1));
428+
book.NoSetterImage = new byte[]{10};
429+
}
430+
431+
Assert.That(NHibernateUtil.IsPropertyInitialized(book, nameof(book.NoSetterImage)), Is.True);
432+
CollectionAssert.AreEqual(book.NoSetterImage, new byte[] { 10 });
433+
}
434+
435+
[Test]
436+
public async Task CanFetchLazyPropertyNoSetterAsync()
437+
{
438+
using (ISession s = OpenSession())
439+
{
440+
var book = await (s
441+
.Query<Book>()
442+
.Fetch(x => x.NoSetterImage)
443+
.FirstAsync(x => x.Id == 1));
444+
445+
Assert.That(NHibernateUtil.IsPropertyInitialized(book, nameof(book.NoSetterImage)), Is.True);
446+
}
447+
}
394448
}
395449
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
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.Linq;
12+
using NHibernate.Linq;
13+
using NUnit.Framework;
14+
15+
namespace NHibernate.Test.NHSpecificTest.GH3288
16+
{
17+
using System.Threading.Tasks;
18+
[TestFixture]
19+
public class FetchAndCollectionJoinFixtureAsync : BugTestCase
20+
{
21+
protected override void OnSetUp()
22+
{
23+
using var session = OpenSession();
24+
using var transaction = session.BeginTransaction();
25+
var middleEntity = new MiddleEntity();
26+
middleEntity.Components.Add(new Component { MiddleEntity = middleEntity, Value = 1 });
27+
var te = new TopEntity
28+
{
29+
MiddleEntity = middleEntity
30+
};
31+
session.Save(middleEntity);
32+
session.Save(te);
33+
34+
transaction.Commit();
35+
}
36+
37+
protected override void OnTearDown()
38+
{
39+
using var session = OpenSession();
40+
using var transaction = session.BeginTransaction();
41+
session.Delete("from System.Object");
42+
43+
transaction.Commit();
44+
}
45+
46+
[Test]
47+
public async Task ReuseEntityJoinWithCollectionJoinAsync()
48+
{
49+
using var session = OpenSession();
50+
51+
var entities = await (session.Query<TopEntity>()
52+
.Fetch(e => e.MiddleEntity)
53+
.Where(e => e.MiddleEntity.Components.Any(e => e.Value != 0))
54+
.ToListAsync());
55+
Assert.That(entities.Count, Is.EqualTo(1));
56+
}
57+
}
58+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
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.Linq;
12+
using NHibernate.Cfg.MappingSchema;
13+
using NHibernate.Linq;
14+
using NHibernate.Mapping.ByCode;
15+
using NUnit.Framework;
16+
17+
namespace NHibernate.Test.NHSpecificTest.GH3289
18+
{
19+
using System.Threading.Tasks;
20+
[TestFixture]
21+
public class ByCodeFixtureAsync : TestCaseMappingByCode
22+
{
23+
protected override HbmMapping GetMappings()
24+
{
25+
var mapper = new ModelMapper();
26+
mapper.Class<Entity>(rc =>
27+
{
28+
rc.Id(x => x.Id, m => m.Generator(Generators.Identity));
29+
rc.Property(x => x.Name);
30+
rc.Component(x => x.Component);
31+
});
32+
mapper.Class<OtherEntity>(rc =>
33+
{
34+
rc.Id(x => x.Id, m => m.Generator(Generators.Identity));
35+
rc.Property(x => x.Name);
36+
rc.Component(x => x.Component);
37+
});
38+
mapper.JoinedSubclass<SubEntity>(rc =>
39+
{
40+
rc.Key(k => k.Column("Id"));
41+
rc.Property(x => x.SomeProperty);
42+
});
43+
mapper.Component<Component>(rc =>
44+
{
45+
rc.Property(x => x.Field);
46+
rc.Lazy(true);
47+
});
48+
49+
return mapper.CompileMappingForAllExplicitlyAddedEntities();
50+
}
51+
52+
protected override void OnSetUp()
53+
{
54+
using var session = OpenSession();
55+
using var transaction = session.BeginTransaction();
56+
var e1 = new SubEntity { Name = "Jim" };
57+
session.Save(e1);
58+
59+
transaction.Commit();
60+
}
61+
62+
protected override void OnTearDown()
63+
{
64+
using var session = OpenSession();
65+
using var transaction = session.BeginTransaction();
66+
67+
if (Dialect.SupportsTemporaryTables)
68+
session.CreateQuery("delete from System.Object").ExecuteUpdate();
69+
else
70+
session.Delete("from System.Object");
71+
72+
transaction.Commit();
73+
}
74+
75+
[Test]
76+
public async Task TestSubEntityInterfaceWithFetchIsPropertyInitializedAsync()
77+
{
78+
using var session = OpenSession();
79+
var data = await (session.Query<ISubEntity>()
80+
.Fetch(e => e.Component)
81+
.ToListAsync());
82+
var result = NHibernateUtil.IsPropertyInitialized(data[0], "Component");
83+
84+
Assert.That(result, Is.True);
85+
}
86+
87+
[Test]
88+
public async Task TestEntityInterfaceWithFetchIsPropertyInitializedAsync()
89+
{
90+
using var session = OpenSession();
91+
var data = await (session.Query<IEntity>()
92+
.Fetch(e => e.Component)
93+
.ToListAsync());
94+
var result = NHibernateUtil.IsPropertyInitialized(data[0], "Component");
95+
96+
Assert.That(result, Is.True);
97+
}
98+
99+
[Test]
100+
public async Task TestSubEntityWithFetchIsPropertyInitializedAsync()
101+
{
102+
using var session = OpenSession();
103+
var data = await (session.Query<SubEntity>()
104+
.Fetch(e => e.Component)
105+
.ToListAsync());
106+
var result = NHibernateUtil.IsPropertyInitialized(data[0], "Component");
107+
108+
Assert.That(result, Is.True);
109+
}
110+
}
111+
}

0 commit comments

Comments
 (0)