Skip to content

Commit 9cc6d95

Browse files
committed
Merge 5.3.13 into master
2 parents 2fd7f0f + 7cc1307 commit 9cc6d95

25 files changed

+704
-55
lines changed

releasenotes.txt

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,27 @@
1-
Build 5.3.12
1+
Build 5.3.13
2+
=============================
3+
4+
Release notes - NHibernate - Version 5.3.13
5+
6+
6 issues were resolved in this release.
7+
8+
** Bug
9+
10+
#3134 ManyToMany - Tries to select not existing column in Mapping Table
11+
#3113 Join fails on Oracle9Dialect
12+
#3030 Memory leak named parameter holds entity references
13+
14+
** Improvement
15+
16+
#3120 Guards against use of a disposed session factory
17+
#2994 Npgsql 6 is not compatible
18+
19+
** Task
20+
21+
* #3145 Release 5.3.13
22+
23+
24+
Build 5.3.12
225
=============================
326

427
Release notes - NHibernate - Version 5.3.12
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
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;
13+
using NHibernate.Cfg.MappingSchema;
14+
using NHibernate.Dialect;
15+
using NHibernate.Mapping.ByCode;
16+
using NUnit.Framework;
17+
using NHibernate.Linq;
18+
19+
namespace NHibernate.Test.NHSpecificTest.GH3113
20+
{
21+
using System.Threading.Tasks;
22+
[TestFixture]
23+
public class ByCodeFixtureAsync : TestCaseMappingByCode
24+
{
25+
protected override HbmMapping GetMappings()
26+
{
27+
var mapper = new ModelMapper();
28+
mapper.Class<Entity>(rc =>
29+
{
30+
rc.Id(x => x.Id, m => m.Generator(Generators.GuidComb));
31+
rc.Property(x => x.Name);
32+
});
33+
34+
return mapper.CompileMappingForAllExplicitlyAddedEntities();
35+
}
36+
37+
protected override bool AppliesTo(Dialect.Dialect dialect)
38+
{
39+
return dialect is Oracle9iDialect;
40+
}
41+
42+
protected override void Configure(Configuration configuration)
43+
{
44+
var dialect = NHibernate.Dialect.Dialect.GetDialect(configuration.Properties);
45+
if (dialect is Oracle8iDialect)
46+
configuration.SetProperty(Environment.Dialect, typeof(Oracle9iDialect).FullName);
47+
48+
base.Configure(configuration);
49+
}
50+
51+
protected override void OnSetUp()
52+
{
53+
using (var session = OpenSession())
54+
using (var transaction = session.BeginTransaction())
55+
{
56+
var e1 = new Entity { Name = "Bob" };
57+
session.Save(e1);
58+
59+
var e2 = new Entity { Name = "Sally" };
60+
session.Save(e2);
61+
62+
transaction.Commit();
63+
}
64+
}
65+
66+
protected override void OnTearDown()
67+
{
68+
using (var session = OpenSession())
69+
using (var transaction = session.BeginTransaction())
70+
{
71+
session.CreateQuery("delete from System.Object").ExecuteUpdate();
72+
73+
transaction.Commit();
74+
}
75+
}
76+
77+
[Test]
78+
public async Task JoinFailsOnOracle9DialectAsync()
79+
{
80+
using (var session = OpenSession())
81+
{
82+
var result = from e in session.Query<Entity>()
83+
join e2 in session.Query<Entity>() on e.Id equals e2.Id
84+
where e.Name == "Bob"
85+
select e.Name;
86+
87+
Assert.That(await (result.ToListAsync()), Has.Count.EqualTo(1));
88+
}
89+
}
90+
}
91+
}
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
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.Collections.Generic;
12+
using System.Linq;
13+
using NHibernate.Cfg.MappingSchema;
14+
using NHibernate.Mapping.ByCode;
15+
using NHibernate.Transform;
16+
using NHibernate.Util;
17+
using NUnit.Framework;
18+
19+
namespace NHibernate.Test.NHSpecificTest.GH3134
20+
{
21+
using System.Threading.Tasks;
22+
[TestFixture]
23+
public class ManyToManyChildFetchByCodeFixtureAsync : TestCaseMappingByCode
24+
{
25+
protected override HbmMapping GetMappings()
26+
{
27+
var mapper = new ModelMapper();
28+
mapper.AddMapping<AMap>();
29+
mapper.AddMapping<BMap>();
30+
31+
return mapper.CompileMappingForAllExplicitlyAddedEntities();
32+
}
33+
protected override void OnSetUp()
34+
{
35+
using (var session = OpenSession())
36+
using (var transaction = session.BeginTransaction())
37+
{
38+
var a1 = new A();
39+
a1.Bs.Add(new B());
40+
a1.Bs.Add(new B());
41+
session.Save(a1);
42+
43+
var a2 = new A();
44+
a2.Bs.Add(new B());
45+
a2.Bs.Add(new B());
46+
session.Save(a2);
47+
48+
transaction.Commit();
49+
}
50+
}
51+
protected override void OnTearDown()
52+
{
53+
using (var session = OpenSession())
54+
using (var transaction = session.BeginTransaction())
55+
{
56+
session.Delete("from System.Object");
57+
58+
transaction.Commit();
59+
}
60+
}
61+
62+
[Test]
63+
public async Task ChildFetchQueryOverAsync()
64+
{
65+
using (var session = OpenSession())
66+
{
67+
session.QueryOver<B>().Future();
68+
69+
session.QueryOver<B>()
70+
.Fetch(SelectMode.ChildFetch, b => b)
71+
.Fetch(SelectMode.Fetch, b => b.As)
72+
.Future();
73+
74+
var result = (await (session.QueryOver<B>()
75+
.Fetch(SelectMode.ChildFetch, b => b, b => b.As)
76+
.Fetch(SelectMode.Fetch, b => b.As.First().Bs)
77+
.TransformUsing(Transformers.DistinctRootEntity)
78+
.Future()
79+
.GetEnumerableAsync()))
80+
.ToList();
81+
82+
Assert.That(result.Count, Is.EqualTo(4));
83+
Assert.That(NHibernateUtil.IsInitialized(result[0].As), Is.True);
84+
Assert.That(NHibernateUtil.IsInitialized(result[0].As.First().Bs), Is.True);
85+
Assert.That(result[0].As.Count, Is.EqualTo(1));
86+
Assert.That(result[0].As.First().Bs.Count, Is.EqualTo(2));
87+
}
88+
}
89+
}
90+
}

src/NHibernate.Test/Async/SessionBuilder/Fixture.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,5 +227,22 @@ private void CanSetOnStateless<T, V>(
227227
Assert.AreEqual(sb, fsb, $"{sbType}: Unexpected fluent return after call with {value}");
228228
}
229229
}
230+
231+
[Test]
232+
public void ThrowWhenUsingSessionFromDisposedFactoryAsync()
233+
{
234+
using (var session = Sfi.OpenSession())
235+
{
236+
try
237+
{
238+
Sfi.Dispose();
239+
Assert.That(() => session.GetAsync<Entity>(Guid.Empty), Throws.InstanceOf(typeof(ObjectDisposedException)));
240+
}
241+
finally
242+
{
243+
RebuildSessionFactory();
244+
}
245+
}
246+
}
230247
}
231248
}
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
using System;
2+
using System.Linq;
3+
using NHibernate.Cfg.MappingSchema;
4+
using NHibernate.Mapping.ByCode;
5+
using NUnit.Framework;
6+
7+
namespace NHibernate.Test.NHSpecificTest.GH3030
8+
{
9+
[TestFixture]
10+
public class ByCodeFixture : TestCaseMappingByCode
11+
{
12+
protected override HbmMapping GetMappings()
13+
{
14+
var mapper = new ModelMapper();
15+
mapper.Class<Entity>(
16+
rc =>
17+
{
18+
rc.Table("Entity");
19+
rc.Id(x => x.Id, m => m.Generator(Generators.Assigned));
20+
});
21+
22+
return mapper.CompileMappingForAllExplicitlyAddedEntities();
23+
}
24+
25+
protected override void OnTearDown()
26+
{
27+
using (var session = OpenSession())
28+
using (var transaction = session.BeginTransaction())
29+
{
30+
session.CreateQuery("delete from System.Object").ExecuteUpdate();
31+
transaction.Commit();
32+
}
33+
}
34+
35+
[Test]
36+
public void LinqShouldNotLeakEntityParameters()
37+
{
38+
WeakReference sessionReference = null;
39+
WeakReference firstReference = null;
40+
WeakReference secondReference = null;
41+
42+
new System.Action(
43+
() =>
44+
{
45+
using (var session = ((DebugSessionFactory) Sfi).ActualFactory.OpenSession())
46+
{
47+
var first = new Entity { Id = 1 };
48+
var second = new Entity { Id = 2 };
49+
50+
_ = session.Query<Entity>().FirstOrDefault(f => f == first);
51+
_ = session.Query<Entity>().FirstOrDefault(f => f == second);
52+
53+
sessionReference = new WeakReference(session, true);
54+
firstReference = new WeakReference(first, true);
55+
secondReference = new WeakReference(second, true);
56+
}
57+
})();
58+
59+
GC.Collect();
60+
GC.WaitForPendingFinalizers();
61+
62+
Assert.That(sessionReference.Target, Is.Null);
63+
Assert.That(firstReference.Target, Is.Null);
64+
Assert.That(secondReference.Target, Is.Null);
65+
}
66+
67+
public class Entity
68+
{
69+
public virtual int Id { get; set; }
70+
}
71+
}
72+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
using System;
2+
3+
namespace NHibernate.Test.NHSpecificTest.GH3113
4+
{
5+
class Entity
6+
{
7+
public virtual Guid Id { get; set; }
8+
public virtual string Name { get; set; }
9+
}
10+
}
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
using System.Linq;
2+
using NHibernate.Cfg;
3+
using NHibernate.Cfg.MappingSchema;
4+
using NHibernate.Dialect;
5+
using NHibernate.Mapping.ByCode;
6+
using NUnit.Framework;
7+
8+
namespace NHibernate.Test.NHSpecificTest.GH3113
9+
{
10+
[TestFixture]
11+
public class ByCodeFixture : TestCaseMappingByCode
12+
{
13+
protected override HbmMapping GetMappings()
14+
{
15+
var mapper = new ModelMapper();
16+
mapper.Class<Entity>(rc =>
17+
{
18+
rc.Id(x => x.Id, m => m.Generator(Generators.GuidComb));
19+
rc.Property(x => x.Name);
20+
});
21+
22+
return mapper.CompileMappingForAllExplicitlyAddedEntities();
23+
}
24+
25+
protected override bool AppliesTo(Dialect.Dialect dialect)
26+
{
27+
return dialect is Oracle9iDialect;
28+
}
29+
30+
protected override void Configure(Configuration configuration)
31+
{
32+
var dialect = NHibernate.Dialect.Dialect.GetDialect(configuration.Properties);
33+
if (dialect is Oracle8iDialect)
34+
configuration.SetProperty(Environment.Dialect, typeof(Oracle9iDialect).FullName);
35+
36+
base.Configure(configuration);
37+
}
38+
39+
protected override void OnSetUp()
40+
{
41+
using (var session = OpenSession())
42+
using (var transaction = session.BeginTransaction())
43+
{
44+
var e1 = new Entity { Name = "Bob" };
45+
session.Save(e1);
46+
47+
var e2 = new Entity { Name = "Sally" };
48+
session.Save(e2);
49+
50+
transaction.Commit();
51+
}
52+
}
53+
54+
protected override void OnTearDown()
55+
{
56+
using (var session = OpenSession())
57+
using (var transaction = session.BeginTransaction())
58+
{
59+
session.CreateQuery("delete from System.Object").ExecuteUpdate();
60+
61+
transaction.Commit();
62+
}
63+
}
64+
65+
[Test]
66+
public void JoinFailsOnOracle9Dialect()
67+
{
68+
using (var session = OpenSession())
69+
{
70+
var result = from e in session.Query<Entity>()
71+
join e2 in session.Query<Entity>() on e.Id equals e2.Id
72+
where e.Name == "Bob"
73+
select e.Name;
74+
75+
Assert.That(result.ToList(), Has.Count.EqualTo(1));
76+
}
77+
}
78+
}
79+
}

0 commit comments

Comments
 (0)