Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 31 additions & 1 deletion releasenotes.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,17 @@
Build 5.5.2
Build 5.5.3
=============================

Release notes - NHibernate - Version 5.5.3

2 issues were resolved in this release.

** Task

* #3692 Release 5.5.3
* #3691 Merge 5.4.10 into 5.5.x


Build 5.5.2
=============================

Release notes - NHibernate - Version 5.5.2
Expand Down Expand Up @@ -122,6 +135,23 @@ Release notes - NHibernate - Version 5.5.0
* #3412 Revive hql ParsingFixture


Build 5.4.10
=============================

Release notes - NHibernate - Version 5.4.10

3 issues were resolved in this release.

** Bug

* #3609 Fitering with a subquery on a many-to-one with property-ref generates invalid SQL
* #3607 Invalid ByCode serialization to XML for OneToOne mappings

** Task

* #3688 Release 5.4.10


Build 5.4.9
=============================

Expand Down
114 changes: 114 additions & 0 deletions src/NHibernate.Test/Async/NHSpecificTest/GH3609/Fixture.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by AsyncGenerator.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------


using System;
using System.Linq;
using NUnit.Framework;
using NHibernate.Linq;

namespace NHibernate.Test.NHSpecificTest.GH3609
{
using System.Threading.Tasks;
[TestFixture]
public class FixtureAsync : BugTestCase
{
protected override void OnSetUp()
{
using var session = OpenSession();
using var transaction = session.BeginTransaction();

var order = new Order
{
UniqueId = "0ab92479-8a17-4dbc-9bef-ce4344940cec",
CreatedDate = new DateTime(2024, 09, 24)
};
session.Save(order);
session.Save(new LineItem { Order = order, ItemName = "Bananas", Amount = 5 });
session.Save(new CleanLineItem { Order = order, ItemName = "Bananas", Amount = 5 });

order = new Order
{
UniqueId = "4ca17d84-97aa-489f-8701-302a3879a388",
CreatedDate = new DateTime(2021, 09, 19)
};
session.Save(order);
session.Save(new LineItem { Order = order, ItemName = "Apples", Amount = 10 });
session.Save(new CleanLineItem { Order = order, ItemName = "Apples", Amount = 10 });

transaction.Commit();
}

protected override void OnTearDown()
{
using var session = OpenSession();
using var transaction = session.BeginTransaction();

session.CreateQuery("delete from CleanLineItem").ExecuteUpdate();
session.CreateQuery("delete from System.Object").ExecuteUpdate();

transaction.Commit();
}

[Test]
public async Task QueryWithAnyAsync()
{
using var session = OpenSession();
using var transaction = session.BeginTransaction();

// This form of query is how we first discovered the issue. This is a simplified reproduction of the
// sort of Linq that we were using in our app. It seems to occur when we force an EXISTS( ... ) subquery.
var validOrders = session.Query<Order>().Where(x => x.CreatedDate > new DateTime(2024, 9, 10));
var orderCount = await (session.Query<LineItem>().CountAsync(x => validOrders.Any(y => y == x.Order)));

Assert.That(orderCount, Is.EqualTo(1));
await (transaction.CommitAsync());
}

[Test]
public async Task QueryWithAnyOnCleanLinesAsync()
{
using var session = OpenSession();
using var transaction = session.BeginTransaction();

// This form of query is how we first discovered the issue. This is a simplified reproduction of the
// sort of Linq that we were using in our app. It seems to occur when we force an EXISTS( ... ) subquery.
var validOrders = session.Query<Order>().Where(x => x.CreatedDate > new DateTime(2024, 9, 10));
var orderCount = await (session.Query<CleanLineItem>().CountAsync(x => validOrders.Any(y => y == x.Order)));

Assert.That(orderCount, Is.EqualTo(1));
await (transaction.CommitAsync());
}

[Test]
public async Task QueryWithContainsAsync()
{
using var session = OpenSession();
using var transaction = session.BeginTransaction();

var validOrders = session.Query<Order>().Where(x => x.CreatedDate > new DateTime(2024, 9, 10));
var orderCount = await (session.Query<LineItem>().CountAsync(x => validOrders.Contains(x.Order)));

Assert.That(orderCount, Is.EqualTo(1));
await (transaction.CommitAsync());
}

[Test]
public async Task SimpleQueryForDataWhichWasInsertedViaAdoShouldProvideExpectedResultsAsync()
{
using var session = OpenSession();
using var transaction = session.BeginTransaction();

// This style of equivalent query does not exhibit the problem. This test passes no matter which NH version.
var lineItem = await (session.Query<LineItem>().FirstOrDefaultAsync(x => x.Order.CreatedDate > new DateTime(2024, 9, 10)));
Assert.That(lineItem, Is.Not.Null);
await (transaction.CommitAsync());
}
}
}
31 changes: 31 additions & 0 deletions src/NHibernate.Test/NHSpecificTest/GH3607/FixtureByCode.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using NHibernate.Cfg;
using NHibernate.Cfg.MappingSchema;
using NHibernate.Mapping.ByCode;
using NUnit.Framework;

namespace NHibernate.Test.NHSpecificTest.GH3607
{
/// <summary>
/// By code mapping serialization failure since v5.4.1. Adapted from <see href="https://github.com/craigfowler/NHibernate.XmlConversionBug" />.
/// </summary>
[TestFixture]
public class FixtureByCode : TestCaseMappingByCode
{
protected override HbmMapping GetMappings()
{
var mapper = new ModelMapper();
mapper.AddMappings(new[] { typeof(OrderMapping), typeof(LineItemMapping), typeof(LineItemDataMapping) });
return mapper.CompileMappingForAllExplicitlyAddedEntities();
}

[Test]
public void SerializeMappingToXml()
{
var mapping = GetMappings();
string serialized = "";
Assert.That(() => serialized = mapping.AsString(), Throws.Nothing, "Mapping serialization failure");
var config = new Configuration();
Assert.That(() => config.AddXml(serialized), Throws.Nothing, "Configuration with serialized mapping has failed");
}
}
}
15 changes: 15 additions & 0 deletions src/NHibernate.Test/NHSpecificTest/GH3607/LineItem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
namespace NHibernate.Test.NHSpecificTest.GH3607
{
public class LineItem
{
public virtual int Id { get; set; }

public virtual Order ParentOrder { get; set; }

public virtual string ItemName { get; set; }

public virtual decimal Amount { get; set; }

public virtual LineItemData Data { get; set; }
}
}
9 changes: 9 additions & 0 deletions src/NHibernate.Test/NHSpecificTest/GH3607/LineItemData.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace NHibernate.Test.NHSpecificTest.GH3607
{
public class LineItemData
{
public virtual LineItem LineItem { get; set; }

public virtual string Data { get; set; }
}
}
14 changes: 14 additions & 0 deletions src/NHibernate.Test/NHSpecificTest/GH3607/LineItemDataMapping.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using NHibernate.Mapping.ByCode.Conformist;

namespace NHibernate.Test.NHSpecificTest.GH3607
{
public class LineItemDataMapping : ClassMapping<LineItemData>
{
public LineItemDataMapping()
{
OneToOne(x => x.LineItem, m => m.Constrained(true));

Property(x => x.Data);
}
}
}
21 changes: 21 additions & 0 deletions src/NHibernate.Test/NHSpecificTest/GH3607/LineItemMapping.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using NHibernate.Mapping.ByCode;
using NHibernate.Mapping.ByCode.Conformist;

namespace NHibernate.Test.NHSpecificTest.GH3607
{
public class LineItemMapping : ClassMapping<LineItem>
{
public LineItemMapping()
{
Id(x => x.Id, m => m.Generator(new IdentityGeneratorDef()));

Property(x => x.ItemName);

Property(x => x.Amount);

ManyToOne(x => x.ParentOrder);

ManyToOne(x => x.Data);
}
}
}
14 changes: 14 additions & 0 deletions src/NHibernate.Test/NHSpecificTest/GH3607/Order.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;

namespace NHibernate.Test.NHSpecificTest.GH3607
{
public class Order
{
public virtual int Id { get; set; }

public virtual DateTime CreatedDate { get; set; }

public virtual ISet<LineItem> Items { get; protected set; } = new HashSet<LineItem>();
}
}
22 changes: 22 additions & 0 deletions src/NHibernate.Test/NHSpecificTest/GH3607/OrderMapping.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using NHibernate.Mapping.ByCode;
using NHibernate.Mapping.ByCode.Conformist;

namespace NHibernate.Test.NHSpecificTest.GH3607
{
public class OrderMapping : ClassMapping<Order>
{
public OrderMapping()
{
Table("`Order`");
Id(x => x.Id, m => m.Generator(new IdentityGeneratorDef()));

Property(x => x.CreatedDate);

Set(x => x.Items, m =>
{
m.Inverse(true);
m.OptimisticLock(true);
}, a => a.OneToMany());
}
}
}
35 changes: 35 additions & 0 deletions src/NHibernate.Test/NHSpecificTest/GH3609/Entities.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using System;

namespace NHibernate.Test.NHSpecificTest.GH3609
{
public class Order
{
public virtual long Id { get; set; }

public virtual string UniqueId { get; set; } = Guid.NewGuid().ToString();

public virtual DateTime CreatedDate { get; set; }
}

public class LineItem
{
public virtual long Id { get; set; }

public virtual Order Order { get; set; }

public virtual string ItemName { get; set; }

public virtual decimal Amount { get; set; }
}

public class CleanLineItem
{
public virtual long Id { get; set; }

public virtual Order Order { get; set; }

public virtual string ItemName { get; set; }

public virtual decimal Amount { get; set; }
}
}
Loading
Loading