Skip to content

Commit d2599c6

Browse files
Merge branch '5.3.x'
# Conflicts: # build-common/NHibernate.props
2 parents df292f1 + 96a9af7 commit d2599c6

22 files changed

+871
-17
lines changed

releasenotes.txt

+20-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,23 @@
1-
Build 5.3.7
1+
Build 5.3.8
2+
=============================
3+
4+
Release notes - NHibernate - Version 5.3.8
5+
6+
6 issues were resolved in this release.
7+
8+
** Bug
9+
10+
* #2710 Filtered Entity Dml Update Throws Collection was modified
11+
* #2708 MappedAs throws when called on a Convert UnaryExpression
12+
* #2707 Don't currently support idents of type X
13+
* #2673 Exception when using BinaryFormatter to deserialize entities with initialized proxies in associations
14+
* #1264 NH-3005 - NHibernate.Hql.Ast.HqlIdent..ctor throws Don't currently support idents of type Date
15+
16+
** Task
17+
18+
* #2721 Release 5.3.8
19+
20+
Build 5.3.7
221
=============================
322

423
Release notes - NHibernate - Version 5.3.7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
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.Generic;
13+
using System.Linq;
14+
using System.Text;
15+
using NHibernate.Linq;
16+
using NUnit.Framework;
17+
18+
namespace NHibernate.Test.Linq.ByMethod
19+
{
20+
using System.Threading.Tasks;
21+
[TestFixture]
22+
public class MappedAsTestsAsync : LinqTestCase
23+
{
24+
[Test]
25+
public async Task WithUnaryExpressionAsync()
26+
{
27+
var num = 1;
28+
await (db.Orders.Where(o => o.Freight == (-num).MappedAs(NHibernateUtil.Decimal)).ToListAsync());
29+
await (db.Orders.Where(o => o.Freight == ((decimal) num).MappedAs(NHibernateUtil.Decimal)).ToListAsync());
30+
await (db.Orders.Where(o => o.Freight == ((decimal?) (decimal) num).MappedAs(NHibernateUtil.Decimal)).ToListAsync());
31+
}
32+
33+
[Test]
34+
public async Task WithNewExpressionAsync()
35+
{
36+
var num = 1;
37+
await (db.Orders.Where(o => o.Freight == new decimal(num).MappedAs(NHibernateUtil.Decimal)).ToListAsync());
38+
}
39+
40+
[Test]
41+
public async Task WithMethodCallExpressionAsync()
42+
{
43+
var num = 1;
44+
await (db.Orders.Where(o => o.Freight == GetDecimal(num).MappedAs(NHibernateUtil.Decimal)).ToListAsync());
45+
}
46+
47+
private decimal GetDecimal(int number)
48+
{
49+
return number;
50+
}
51+
}
52+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
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.IO;
12+
using System.Runtime.Serialization;
13+
using System.Runtime.Serialization.Formatters.Binary;
14+
using NHibernate.Cfg.MappingSchema;
15+
using NHibernate.Mapping.ByCode;
16+
using NUnit.Framework;
17+
18+
namespace NHibernate.Test.NHSpecificTest.GH2673
19+
{
20+
using System.Threading.Tasks;
21+
[TestFixture(true)]
22+
[TestFixture(false)]
23+
public class FixtureAsync : TestCaseMappingByCode
24+
{
25+
private readonly bool _withLazyProperties;
26+
27+
public FixtureAsync(bool withLazyProperties)
28+
{
29+
_withLazyProperties = withLazyProperties;
30+
}
31+
32+
protected override void OnSetUp()
33+
{
34+
using (var session = OpenSession())
35+
using (var transaction = session.BeginTransaction())
36+
{
37+
var role1 = new Role {Id = 1, Name = "role1"};
38+
session.Save(role1);
39+
var role2 = new Role {Id = 2, Name = "role2"};
40+
session.Save(role2);
41+
42+
var r1 = new Resource() {Id = 1, Name = "r1", ResourceRole = role1};
43+
session.Save(r1);
44+
45+
var r2 = new Resource() {Id = 2, Name = "r2", ResourceRole = role2};
46+
session.Save(r2);
47+
48+
var r3 = new Resource() {Id = 3, Name = "r3", ResourceRole = role2};
49+
session.Save(r3);
50+
51+
r1.Manager = r2;
52+
r2.Manager = r3;
53+
r3.Manager = r1;
54+
transaction.Commit();
55+
}
56+
}
57+
58+
protected override void OnTearDown()
59+
{
60+
using (var session = OpenSession())
61+
using (var transaction = session.BeginTransaction())
62+
{
63+
session.CreateQuery("delete from System.Object").ExecuteUpdate();
64+
65+
transaction.Commit();
66+
}
67+
}
68+
69+
[Test]
70+
public async Task DeserializeSameTypeAssociationWithInitializedProxyAndCircularReferencesAsync()
71+
{
72+
using (var session = OpenSession())
73+
{
74+
var r1 = await (session.LoadAsync<Resource>(1));
75+
var r2 = await (session.LoadAsync<Resource>(2));
76+
var r3 = await (session.LoadAsync<Resource>(3));
77+
78+
var list = await (session.QueryOver<Resource>()
79+
.Fetch(SelectMode.Fetch, res => res.Manager)
80+
.ListAsync());
81+
82+
try
83+
{
84+
var serialised = SpoofSerialization(list[0]);
85+
SpoofSerialization(session);
86+
}
87+
catch (SerializationException)
88+
{
89+
//Lazy properties case throws due to circular references. See GH-2563
90+
if (!_withLazyProperties)
91+
throw;
92+
}
93+
}
94+
}
95+
96+
[Test]
97+
public async Task DeserializeSameTypeAssociationWithInitializedAndNotInitializedProxyAsync()
98+
{
99+
using (var session = OpenSession())
100+
{
101+
var r1 = await (session.GetAsync<Resource>(1));
102+
var r2 = await (session.GetAsync<Resource>(2));
103+
var r1Name = r1.Name;
104+
var serialised = SpoofSerialization(r1);
105+
Assert.That(serialised.Name, Is.EqualTo("r1"));
106+
}
107+
}
108+
109+
private T SpoofSerialization<T>(T obj)
110+
{
111+
var formatter = new BinaryFormatter
112+
{
113+
#if !NETFX
114+
SurrogateSelector = new NHibernate.Util.SerializationHelper.SurrogateSelector()
115+
#endif
116+
};
117+
var stream = new MemoryStream();
118+
formatter.Serialize(stream, obj);
119+
120+
stream.Position = 0;
121+
122+
return (T) formatter.Deserialize(stream);
123+
}
124+
125+
protected override HbmMapping GetMappings()
126+
{
127+
var mapper = new ModelMapper();
128+
mapper.Class<Resource>(
129+
m =>
130+
{
131+
m.Table("ResTable");
132+
m.Id(x => x.Id, (i) => i.Generator(Generators.Assigned));
133+
m.Property(x => x.Name, x => x.Lazy(_withLazyProperties));
134+
m.ManyToOne(x => x.Manager, x => x.ForeignKey("none"));
135+
m.ManyToOne(x => x.ResourceRole, x => x.ForeignKey("none"));
136+
});
137+
mapper.Class<Role>(
138+
m =>
139+
{
140+
m.Table("RoleTable");
141+
m.Id(x => x.Id, (i) => i.Generator(Generators.Assigned));
142+
m.Property(x => x.Name);
143+
});
144+
return mapper.CompileMappingForAllExplicitlyAddedEntities();
145+
}
146+
}
147+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
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.Mapping.ByCode;
14+
using NUnit.Framework;
15+
using NHibernate.Linq;
16+
17+
namespace NHibernate.Test.NHSpecificTest.GH2707
18+
{
19+
using System.Threading.Tasks;
20+
[TestFixture]
21+
public class ConditionalFixtureAsync : TestCaseMappingByCode
22+
{
23+
protected override HbmMapping GetMappings()
24+
{
25+
var mapper = new ModelMapper();
26+
27+
mapper.AddMapping<Entity1Map>();
28+
return mapper.CompileMappingForAllExplicitlyAddedEntities();
29+
}
30+
31+
protected override void OnSetUp()
32+
{
33+
using (var session = OpenSession())
34+
using (var transaction = session.BeginTransaction())
35+
{
36+
var e1 = new Entity1() {Id = "id1", IsChiusa = true};
37+
e1.CustomType = new MyType() {ToPersist = 1};
38+
session.Save(e1);
39+
var e2 = new Entity1() {Id = "id2", IsChiusa = false};
40+
session.Save(e2);
41+
e1.Parent = e1;
42+
transaction.Commit();
43+
}
44+
}
45+
46+
protected override void OnTearDown()
47+
{
48+
using (var session = OpenSession())
49+
using (var transaction = session.BeginTransaction())
50+
{
51+
session.CreateQuery("delete from System.Object").ExecuteUpdate();
52+
transaction.Commit();
53+
}
54+
}
55+
56+
[Test]
57+
public async Task EntityAndCustomTypeInConditionalResultAsync()
58+
{
59+
using (var s = OpenSession())
60+
await ((from x in s.Query<Entity1>()
61+
let parent = x.Parent
62+
//NH-3005 - Conditional with custom type
63+
where (parent.IsChiusa ? x.CustomType : parent.CustomType) == x.CustomType
64+
select new
65+
{
66+
ParentIsChiusa = (((x == null) ? null : x.Parent) == null)
67+
? (bool?) null
68+
: x.Parent.IsChiusa,
69+
}).ToListAsync());
70+
}
71+
}
72+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
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 System.Threading.Tasks;
14+
using NHibernate.Linq;
15+
using NUnit.Framework;
16+
17+
namespace NHibernate.Test.NHSpecificTest.GH2710
18+
{
19+
using System.Threading;
20+
[TestFixture]
21+
public class FixtureAsync : BugTestCase
22+
{
23+
protected override void OnSetUp()
24+
{
25+
using (var session = OpenSession())
26+
using (var transaction = session.BeginTransaction())
27+
{
28+
var e = new Entity {MbrId = 1, MrcDailyMoved = "N"};
29+
session.Save(e);
30+
31+
transaction.Commit();
32+
}
33+
}
34+
35+
protected override void OnTearDown()
36+
{
37+
using (var session = OpenSession())
38+
using (var transaction = session.BeginTransaction())
39+
{
40+
session.CreateQuery("delete from Entity").ExecuteUpdate();
41+
session.CreateQuery("delete from System.Object").ExecuteUpdate();
42+
43+
transaction.Commit();
44+
}
45+
}
46+
47+
[Test]
48+
public async Task TestAsync()
49+
{
50+
var ids = Enumerable.Range(1, 10).ToList();
51+
await (Task.WhenAll(Enumerable.Range(1, 50 - 1).Select(i =>
52+
{
53+
return UpdateEntityAsync(ids);
54+
})));
55+
}
56+
57+
private async Task UpdateEntityAsync(List<int> ids, CancellationToken cancellationToken = default(CancellationToken))
58+
{
59+
using (var session = OpenSession())
60+
using (var t = session.BeginTransaction())
61+
{
62+
session.EnableFilter("Filter").SetParameter("MbrId", 5);
63+
await (session.Query<Entity>()
64+
.Where(o => ids.Contains(o.Id))
65+
.UpdateAsync(o => new Entity { MrcDailyMoved = "Y" }, cancellationToken));
66+
67+
await (t.CommitAsync(cancellationToken));
68+
}
69+
}
70+
}
71+
}

0 commit comments

Comments
 (0)