Skip to content

Commit 8d733cd

Browse files
Merge 5.5.3 into master
2 parents adb19e3 + e9b5d23 commit 8d733cd

File tree

14 files changed

+456
-8
lines changed

14 files changed

+456
-8
lines changed

releasenotes.txt

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,17 @@
1-
Build 5.5.2
1+
Build 5.5.3
2+
=============================
3+
4+
Release notes - NHibernate - Version 5.5.3
5+
6+
2 issues were resolved in this release.
7+
8+
** Task
9+
10+
* #3692 Release 5.5.3
11+
* #3691 Merge 5.4.10 into 5.5.x
12+
13+
14+
Build 5.5.2
215
=============================
316

417
Release notes - NHibernate - Version 5.5.2
@@ -122,6 +135,23 @@ Release notes - NHibernate - Version 5.5.0
122135
* #3412 Revive hql ParsingFixture
123136

124137

138+
Build 5.4.10
139+
=============================
140+
141+
Release notes - NHibernate - Version 5.4.10
142+
143+
3 issues were resolved in this release.
144+
145+
** Bug
146+
147+
* #3609 Fitering with a subquery on a many-to-one with property-ref generates invalid SQL
148+
* #3607 Invalid ByCode serialization to XML for OneToOne mappings
149+
150+
** Task
151+
152+
* #3688 Release 5.4.10
153+
154+
125155
Build 5.4.9
126156
=============================
127157

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
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.Linq;
13+
using NUnit.Framework;
14+
using NHibernate.Linq;
15+
16+
namespace NHibernate.Test.NHSpecificTest.GH3609
17+
{
18+
using System.Threading.Tasks;
19+
[TestFixture]
20+
public class FixtureAsync : BugTestCase
21+
{
22+
protected override void OnSetUp()
23+
{
24+
using var session = OpenSession();
25+
using var transaction = session.BeginTransaction();
26+
27+
var order = new Order
28+
{
29+
UniqueId = "0ab92479-8a17-4dbc-9bef-ce4344940cec",
30+
CreatedDate = new DateTime(2024, 09, 24)
31+
};
32+
session.Save(order);
33+
session.Save(new LineItem { Order = order, ItemName = "Bananas", Amount = 5 });
34+
session.Save(new CleanLineItem { Order = order, ItemName = "Bananas", Amount = 5 });
35+
36+
order = new Order
37+
{
38+
UniqueId = "4ca17d84-97aa-489f-8701-302a3879a388",
39+
CreatedDate = new DateTime(2021, 09, 19)
40+
};
41+
session.Save(order);
42+
session.Save(new LineItem { Order = order, ItemName = "Apples", Amount = 10 });
43+
session.Save(new CleanLineItem { Order = order, ItemName = "Apples", Amount = 10 });
44+
45+
transaction.Commit();
46+
}
47+
48+
protected override void OnTearDown()
49+
{
50+
using var session = OpenSession();
51+
using var transaction = session.BeginTransaction();
52+
53+
session.CreateQuery("delete from CleanLineItem").ExecuteUpdate();
54+
session.CreateQuery("delete from System.Object").ExecuteUpdate();
55+
56+
transaction.Commit();
57+
}
58+
59+
[Test]
60+
public async Task QueryWithAnyAsync()
61+
{
62+
using var session = OpenSession();
63+
using var transaction = session.BeginTransaction();
64+
65+
// This form of query is how we first discovered the issue. This is a simplified reproduction of the
66+
// sort of Linq that we were using in our app. It seems to occur when we force an EXISTS( ... ) subquery.
67+
var validOrders = session.Query<Order>().Where(x => x.CreatedDate > new DateTime(2024, 9, 10));
68+
var orderCount = await (session.Query<LineItem>().CountAsync(x => validOrders.Any(y => y == x.Order)));
69+
70+
Assert.That(orderCount, Is.EqualTo(1));
71+
await (transaction.CommitAsync());
72+
}
73+
74+
[Test]
75+
public async Task QueryWithAnyOnCleanLinesAsync()
76+
{
77+
using var session = OpenSession();
78+
using var transaction = session.BeginTransaction();
79+
80+
// This form of query is how we first discovered the issue. This is a simplified reproduction of the
81+
// sort of Linq that we were using in our app. It seems to occur when we force an EXISTS( ... ) subquery.
82+
var validOrders = session.Query<Order>().Where(x => x.CreatedDate > new DateTime(2024, 9, 10));
83+
var orderCount = await (session.Query<CleanLineItem>().CountAsync(x => validOrders.Any(y => y == x.Order)));
84+
85+
Assert.That(orderCount, Is.EqualTo(1));
86+
await (transaction.CommitAsync());
87+
}
88+
89+
[Test]
90+
public async Task QueryWithContainsAsync()
91+
{
92+
using var session = OpenSession();
93+
using var transaction = session.BeginTransaction();
94+
95+
var validOrders = session.Query<Order>().Where(x => x.CreatedDate > new DateTime(2024, 9, 10));
96+
var orderCount = await (session.Query<LineItem>().CountAsync(x => validOrders.Contains(x.Order)));
97+
98+
Assert.That(orderCount, Is.EqualTo(1));
99+
await (transaction.CommitAsync());
100+
}
101+
102+
[Test]
103+
public async Task SimpleQueryForDataWhichWasInsertedViaAdoShouldProvideExpectedResultsAsync()
104+
{
105+
using var session = OpenSession();
106+
using var transaction = session.BeginTransaction();
107+
108+
// This style of equivalent query does not exhibit the problem. This test passes no matter which NH version.
109+
var lineItem = await (session.Query<LineItem>().FirstOrDefaultAsync(x => x.Order.CreatedDate > new DateTime(2024, 9, 10)));
110+
Assert.That(lineItem, Is.Not.Null);
111+
await (transaction.CommitAsync());
112+
}
113+
}
114+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
using NHibernate.Cfg;
2+
using NHibernate.Cfg.MappingSchema;
3+
using NHibernate.Mapping.ByCode;
4+
using NUnit.Framework;
5+
6+
namespace NHibernate.Test.NHSpecificTest.GH3607
7+
{
8+
/// <summary>
9+
/// By code mapping serialization failure since v5.4.1. Adapted from <see href="https://github.com/craigfowler/NHibernate.XmlConversionBug" />.
10+
/// </summary>
11+
[TestFixture]
12+
public class FixtureByCode : TestCaseMappingByCode
13+
{
14+
protected override HbmMapping GetMappings()
15+
{
16+
var mapper = new ModelMapper();
17+
mapper.AddMappings(new[] { typeof(OrderMapping), typeof(LineItemMapping), typeof(LineItemDataMapping) });
18+
return mapper.CompileMappingForAllExplicitlyAddedEntities();
19+
}
20+
21+
[Test]
22+
public void SerializeMappingToXml()
23+
{
24+
var mapping = GetMappings();
25+
string serialized = "";
26+
Assert.That(() => serialized = mapping.AsString(), Throws.Nothing, "Mapping serialization failure");
27+
var config = new Configuration();
28+
Assert.That(() => config.AddXml(serialized), Throws.Nothing, "Configuration with serialized mapping has failed");
29+
}
30+
}
31+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
namespace NHibernate.Test.NHSpecificTest.GH3607
2+
{
3+
public class LineItem
4+
{
5+
public virtual int Id { get; set; }
6+
7+
public virtual Order ParentOrder { get; set; }
8+
9+
public virtual string ItemName { get; set; }
10+
11+
public virtual decimal Amount { get; set; }
12+
13+
public virtual LineItemData Data { get; set; }
14+
}
15+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
namespace NHibernate.Test.NHSpecificTest.GH3607
2+
{
3+
public class LineItemData
4+
{
5+
public virtual LineItem LineItem { get; set; }
6+
7+
public virtual string Data { get; set; }
8+
}
9+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using NHibernate.Mapping.ByCode.Conformist;
2+
3+
namespace NHibernate.Test.NHSpecificTest.GH3607
4+
{
5+
public class LineItemDataMapping : ClassMapping<LineItemData>
6+
{
7+
public LineItemDataMapping()
8+
{
9+
OneToOne(x => x.LineItem, m => m.Constrained(true));
10+
11+
Property(x => x.Data);
12+
}
13+
}
14+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
using NHibernate.Mapping.ByCode;
2+
using NHibernate.Mapping.ByCode.Conformist;
3+
4+
namespace NHibernate.Test.NHSpecificTest.GH3607
5+
{
6+
public class LineItemMapping : ClassMapping<LineItem>
7+
{
8+
public LineItemMapping()
9+
{
10+
Id(x => x.Id, m => m.Generator(new IdentityGeneratorDef()));
11+
12+
Property(x => x.ItemName);
13+
14+
Property(x => x.Amount);
15+
16+
ManyToOne(x => x.ParentOrder);
17+
18+
ManyToOne(x => x.Data);
19+
}
20+
}
21+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using System;
2+
using System.Collections.Generic;
3+
4+
namespace NHibernate.Test.NHSpecificTest.GH3607
5+
{
6+
public class Order
7+
{
8+
public virtual int Id { get; set; }
9+
10+
public virtual DateTime CreatedDate { get; set; }
11+
12+
public virtual ISet<LineItem> Items { get; protected set; } = new HashSet<LineItem>();
13+
}
14+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
using NHibernate.Mapping.ByCode;
2+
using NHibernate.Mapping.ByCode.Conformist;
3+
4+
namespace NHibernate.Test.NHSpecificTest.GH3607
5+
{
6+
public class OrderMapping : ClassMapping<Order>
7+
{
8+
public OrderMapping()
9+
{
10+
Table("`Order`");
11+
Id(x => x.Id, m => m.Generator(new IdentityGeneratorDef()));
12+
13+
Property(x => x.CreatedDate);
14+
15+
Set(x => x.Items, m =>
16+
{
17+
m.Inverse(true);
18+
m.OptimisticLock(true);
19+
}, a => a.OneToMany());
20+
}
21+
}
22+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
using System;
2+
3+
namespace NHibernate.Test.NHSpecificTest.GH3609
4+
{
5+
public class Order
6+
{
7+
public virtual long Id { get; set; }
8+
9+
public virtual string UniqueId { get; set; } = Guid.NewGuid().ToString();
10+
11+
public virtual DateTime CreatedDate { get; set; }
12+
}
13+
14+
public class LineItem
15+
{
16+
public virtual long Id { get; set; }
17+
18+
public virtual Order Order { get; set; }
19+
20+
public virtual string ItemName { get; set; }
21+
22+
public virtual decimal Amount { get; set; }
23+
}
24+
25+
public class CleanLineItem
26+
{
27+
public virtual long Id { get; set; }
28+
29+
public virtual Order Order { get; set; }
30+
31+
public virtual string ItemName { get; set; }
32+
33+
public virtual decimal Amount { get; set; }
34+
}
35+
}

0 commit comments

Comments
 (0)