Skip to content

Commit c5e9233

Browse files
authored
Merge branch 'master' into renovate/oracle.manageddataaccess
2 parents 7e93f95 + 555d340 commit c5e9233

File tree

85 files changed

+2731
-3885
lines changed

Some content is hidden

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

85 files changed

+2731
-3885
lines changed

releasenotes.txt

+53-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,40 @@
1-
Build 5.4.3
1+
Build 5.4.5
2+
=============================
3+
4+
Release notes - NHibernate - Version 5.4.5
5+
6+
2 issues were resolved in this release.
7+
8+
** Task
9+
10+
* #3408 Release 5.4.4
11+
* #3407 Release Merge 5.3.19 in 5.4.x
12+
13+
14+
Build 5.4.4
15+
=============================
16+
17+
Release notes - NHibernate - Version 5.4.4
18+
19+
6 issues were resolved in this release.
20+
21+
** Bug
22+
23+
* #3359 2nd level cache GetMany ineffective for collections
24+
* #3354 Invalid program generated by FieldInterceptorProxyBuilder for indexer property getter
25+
* #3352 Fetch throws "could not resolve property" error for a property that is not mapped
26+
27+
** Improvement
28+
29+
* #3368 Allow internal entity classes/interfaces in .NET Standard 2.0 for field interceptor
30+
31+
** Task
32+
33+
* #3386 Release 5.4.4
34+
* #3367 Update readme with actual dev build information for 5.4
35+
36+
37+
Build 5.4.3
238
=============================
339

440
Release notes - NHibernate - Version 5.4.3
@@ -259,6 +295,22 @@ Release notes - NHibernate - Version 5.4.0
259295
* #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
260296

261297

298+
Build 5.3.19
299+
=============================
300+
301+
Release notes - NHibernate - Version 5.3.19
302+
303+
2 issues were resolved in this release.
304+
305+
** Bug
306+
307+
* #3397 GenerateSchemaCreationScript creates many identical dialect instances
308+
309+
** Task
310+
311+
* #3405 Release 5.3.19
312+
313+
262314
Build 5.3.18
263315
=============================
264316

src/NHibernate.Test/Async/CacheTest/BatchableCacheFixture.cs

+72-1
Original file line numberDiff line numberDiff line change
@@ -1565,8 +1565,79 @@ public async Task QueryFetchEntityBatchCacheTestAsync(bool clearEntityCacheAfter
15651565
Assert.That(Sfi.Statistics.QueryCacheHitCount, Is.EqualTo(future ? 2 : 1), "Unexpected cache hit count");
15661566
}
15671567

1568+
[Test]
1569+
public async Task CollectionLazyInitializationFromCacheIsBatchedAsync()
1570+
{
1571+
using (var s = OpenSession())
1572+
{
1573+
var readOnly = await (s.GetAsync<ReadOnly>(await (s.Query<ReadOnly>().Select(x => x.Id).FirstAsync())));
1574+
Assert.That(readOnly.Items.Count, Is.EqualTo(6));
1575+
}
1576+
1577+
var itemPersister = Sfi.GetEntityPersister(typeof(ReadOnlyItem).FullName);
1578+
var itemCache = (BatchableCache) itemPersister.Cache.Cache;
1579+
itemCache.ClearStatistics();
1580+
1581+
using (var s = OpenSession())
1582+
{
1583+
var readOnly = await (s.GetAsync<ReadOnly>(await (s.Query<ReadOnly>().Select(x => x.Id).FirstAsync())));
1584+
Assert.That(readOnly.Items.Count, Is.EqualTo(6));
1585+
}
1586+
1587+
// 6 items with batch-size = 4 so 2 GetMany calls are expected 1st call: 4 items + 2nd call: 2 items
1588+
Assert.That(itemCache.GetMultipleCalls.Count, Is.EqualTo(2));
1589+
}
1590+
1591+
[Test]
1592+
public async Task CollectionLazyInitializationFromCacheIsBatched_FillCacheByQueryCacheAsync()
1593+
{
1594+
var itemPersister = Sfi.GetEntityPersister(typeof(ReadOnlyItem).FullName);
1595+
var itemCache = (BatchableCache) itemPersister.Cache.Cache;
1596+
itemCache.ClearStatistics();
1597+
int id;
1598+
using (var s = OpenSession())
1599+
{
1600+
id = await (s.Query<ReadOnly>().Select(x => x.Id).FirstAsync());
1601+
var readOnly = (await (s.Query<ReadOnly>().Fetch(x => x.Items)
1602+
.Where(x => x.Id == id)
1603+
.WithOptions(x => x.SetCacheable(true))
1604+
.ToListAsync()))
1605+
.First();
1606+
Assert.That(itemCache.PutMultipleCalls.Count, Is.EqualTo(1));
1607+
Assert.That(itemCache.GetMultipleCalls.Count, Is.EqualTo(0));
1608+
Assert.That(NHibernateUtil.IsInitialized(readOnly.Items));
1609+
Assert.That(readOnly.Items.Count, Is.EqualTo(6));
1610+
}
1611+
1612+
itemCache.ClearStatistics();
1613+
using (var s = OpenSession())
1614+
{
1615+
var readOnly = (await (s.Query<ReadOnly>().Fetch(x => x.Items)
1616+
.Where(x => x.Id == id)
1617+
.WithOptions(x => x.SetCacheable(true))
1618+
.ToListAsync()))
1619+
.First();
1620+
Assert.That(itemCache.PutMultipleCalls.Count, Is.EqualTo(0));
1621+
Assert.That(itemCache.GetMultipleCalls.Count, Is.EqualTo(1));
1622+
Assert.That(NHibernateUtil.IsInitialized(readOnly.Items));
1623+
Assert.That(readOnly.Items.Count, Is.EqualTo(6));
1624+
}
1625+
1626+
itemCache.ClearStatistics();
1627+
1628+
1629+
using (var s = OpenSession())
1630+
{
1631+
var readOnly = await (s.GetAsync<ReadOnly>(id));
1632+
Assert.That(readOnly.Items.Count, Is.EqualTo(6));
1633+
}
1634+
1635+
// 6 items with batch-size = 4 so 2 GetMany calls are expected 1st call: 4 items + 2nd call: 2 items
1636+
Assert.That(itemCache.GetMultipleCalls.Count, Is.EqualTo(2));
1637+
}
1638+
15681639
private async Task AssertMultipleCacheCallsAsync<TEntity>(IEnumerable<int> loadIds, IReadOnlyList<int> getIds, int idIndex,
1569-
int[][] fetchedIdIndexes, int[] putIdIndexes, Func<int, bool> cacheBeforeLoadFn = null, CancellationToken cancellationToken = default(CancellationToken))
1640+
int[][] fetchedIdIndexes, int[] putIdIndexes, Func<int, bool> cacheBeforeLoadFn = null, CancellationToken cancellationToken = default(CancellationToken))
15701641
where TEntity : CacheEntity
15711642
{
15721643
var persister = Sfi.GetEntityPersister(typeof(TEntity).FullName);

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

+12
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,18 @@ public async Task TestLinqFetchPropertyAsync()
186186
AssertFetchProperty(person);
187187
}
188188

189+
[Test]
190+
public async Task TestLinqFetchPropertyAfterSelectAsync()
191+
{
192+
using var s = OpenSession();
193+
var owner = await (s.Query<Animal>()
194+
.Select(a => a.Owner)
195+
.Fetch(o => o.Image)
196+
.FirstOrDefaultAsync(o => o.Id == 1));
197+
198+
AssertFetchProperty(owner);
199+
}
200+
189201
private static void AssertFetchProperty(Person person)
190202
{
191203
Assert.That(person, Is.Not.Null);

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

+3
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,9 @@ public async Task CanGetValueForNonLazyPropertyAsync()
230230
Assert.That(book.Name, Is.EqualTo("some name"));
231231
Assert.That(book.FieldInterceptor, Is.EqualTo("Why not that name?"));
232232
Assert.That(NHibernateUtil.IsPropertyInitialized(book, "ALotOfText"), Is.False);
233+
//GH-3354 Exception accessing indexer property
234+
Assert.That(book[0], Is.EqualTo(0));
235+
Assert.DoesNotThrow(() => book[0] = 0);
233236
}
234237
}
235238

src/NHibernate.Test/Async/NHSpecificTest/GH1994/Fixture.cs renamed to src/NHibernate.Test/Async/NHSpecificTest/GH1994/ManyToManyFilteredFixture.cs

+27-12
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
using System.Linq;
1212
using NHibernate.Criterion;
13-
using NHibernate.Dialect;
1413
using NHibernate.Linq;
1514
using NHibernate.SqlCommand;
1615
using NHibernate.Transform;
@@ -20,7 +19,7 @@ namespace NHibernate.Test.NHSpecificTest.GH1994
2019
{
2120
using System.Threading.Tasks;
2221
[TestFixture]
23-
public class FixtureAsync : BugTestCase
22+
public class ManyToManyFilteredFixtureAsync : BugTestCase
2423
{
2524
protected override void OnSetUp()
2625
{
@@ -41,14 +40,7 @@ protected override void OnTearDown()
4140
using (var session = OpenSession())
4241
using (var transaction = session.BeginTransaction())
4342
{
44-
// The HQL delete does all the job inside the database without loading the entities, but it does
45-
// not handle delete order for avoiding violating constraints if any. Use
46-
// session.Delete("from System.Object");
47-
// instead if in need of having NHibernate ordering the deletes, but this will cause
48-
// loading the entities in the session.
49-
5043
session.Delete("from System.Object");
51-
5244
transaction.Commit();
5345
}
5446
}
@@ -70,9 +62,6 @@ public async Task TestUnfilteredLinqQueryAsync()
7062
[Test]
7163
public async Task TestFilteredByWhereCollectionLinqQueryAsync()
7264
{
73-
if(Dialect is PostgreSQLDialect)
74-
Assert.Ignore("Dialect doesn't support 0/1 to bool implicit cast");
75-
7665
using (var s = OpenSession())
7766
{
7867
var query = await (s.Query<Asset>()
@@ -150,5 +139,31 @@ public async Task TestQueryOverRestrictionWithClauseAsync()
150139
Assert.That(query[0].Documents.Count, Is.EqualTo(1), "filtered asset documents");
151140
}
152141
}
142+
143+
[Test]
144+
public async Task LazyLoadAsync()
145+
{
146+
using (var s = OpenSession())
147+
{
148+
var asset = await (s.Query<Asset>().FirstAsync());
149+
Assert.That(asset.Documents.Count, Is.EqualTo(2));
150+
Assert.That(asset.DocumentsBag.Count, Is.EqualTo(2));
151+
Assert.That(asset.DocumentsFiltered.Count, Is.EqualTo(1));
152+
}
153+
}
154+
155+
[Test]
156+
public async Task LazyLoadFilteredAsync()
157+
{
158+
using (var s = OpenSession())
159+
{
160+
s.EnableFilter("deletedFilter").SetParameter("deletedParam", false);
161+
162+
var asset = await (s.Query<Asset>().FirstAsync());
163+
Assert.That(asset.Documents.Count, Is.EqualTo(1));
164+
Assert.That(asset.DocumentsBag.Count, Is.EqualTo(1));
165+
Assert.That(asset.DocumentsFiltered.Count, Is.EqualTo(1));
166+
}
167+
}
153168
}
154169
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
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.Data;
12+
using NHibernate.Dialect;
13+
using NHibernate.SqlTypes;
14+
using NUnit.Framework;
15+
16+
namespace NHibernate.Test.NHSpecificTest.GH3311SqlQueryParam
17+
{
18+
using System.Threading.Tasks;
19+
[TestFixture]
20+
public class SqlQueryParamTypeFixtureAsync : BugTestCase
21+
{
22+
protected override void OnSetUp()
23+
{
24+
using var session = OpenSession();
25+
using var transaction = session.BeginTransaction();
26+
var e1 = new Entity {Name = "Bob"};
27+
session.Save(e1);
28+
29+
var e2 = new Entity {Name = "Sally"};
30+
session.Save(e2);
31+
32+
transaction.Commit();
33+
}
34+
35+
protected override bool AppliesTo(Dialect.Dialect dialect)
36+
{
37+
return
38+
//Dialects like SQL Server CE, Firebird don't distinguish AnsiString from String
39+
(Dialect.GetTypeName(new SqlType(DbType.AnsiString)) != Dialect.GetTypeName(new SqlType(DbType.String))
40+
|| Dialect is SQLiteDialect);
41+
}
42+
43+
protected override void OnTearDown()
44+
{
45+
using var session = OpenSession();
46+
using var transaction = session.BeginTransaction();
47+
session.CreateQuery("delete from System.Object").ExecuteUpdate();
48+
49+
transaction.Commit();
50+
}
51+
52+
[Test]
53+
public async Task AppliesParameterTypeFromQueryParamAsync()
54+
{
55+
using var log = new SqlLogSpy();
56+
using var s = OpenSession();
57+
await (s.GetNamedQuery("entityIdByName").SetParameter("name", "Bob").UniqueResultAsync<object>());
58+
Assert.That(log.GetWholeLog(), Does.Contain("Type: AnsiString"));
59+
}
60+
}
61+
}

src/NHibernate.Test/Async/NHSpecificTest/GH3327/Fixture.cs

+16
Original file line numberDiff line numberDiff line change
@@ -59,5 +59,21 @@ WHERE NOT (
5959
)");
6060
Assert.That((await (q.ListAsync()))[0], Is.EqualTo(0));
6161
}
62+
63+
[Test]
64+
public async Task NotNotExistsNegatedAsync()
65+
{
66+
using var log = new SqlLogSpy();
67+
using var session = OpenSession();
68+
var results = await (session.CreateQuery(
69+
@"SELECT COUNT(ROOT.Id)
70+
FROM Entity AS ROOT
71+
WHERE NOT (
72+
NOT EXISTS (FROM ChildEntity AS CHILD WHERE CHILD.Parent = ROOT)
73+
AND NOT ROOT.Name = 'Parent'
74+
)").ListAsync());
75+
Assert.That(log.GetWholeLog(), Does.Not.Contains(" NOT ").IgnoreCase);
76+
Assert.That(results.Count, Is.EqualTo(1));
77+
}
6278
}
6379
}

0 commit comments

Comments
 (0)