Skip to content

Commit 1605507

Browse files
Merge 5.5.1 into master
2 parents d1790e7 + f25b398 commit 1605507

File tree

13 files changed

+216
-5
lines changed

13 files changed

+216
-5
lines changed

releasenotes.txt

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,21 @@
1-
Build 5.5.0
1+
Build 5.5.1
2+
=============================
3+
4+
Release notes - NHibernate - Version 5.5.1
5+
6+
3 issues were resolved in this release.
7+
8+
** Bug
9+
10+
* #3465 Invalid SQL created for some joins in a subquery
11+
12+
** Task
13+
14+
* #3509 Release 5.5.1
15+
* #3508 Merge 5.4.8 into 5.5.x
16+
17+
18+
Build 5.5.0
219
=============================
320

421
Release notes - NHibernate - Version 5.5.0
@@ -88,6 +105,22 @@ Release notes - NHibernate - Version 5.5.0
88105
* #3412 Revive hql ParsingFixture
89106

90107

108+
Build 5.4.8
109+
=============================
110+
111+
Release notes - NHibernate - Version 5.4.8
112+
113+
2 issues were resolved in this release.
114+
115+
** Bug
116+
117+
* #3489 Inserting multiple associations of the same entity fails
118+
119+
** Task
120+
121+
* #3507 Release 5.4.8
122+
123+
91124
Build 5.4.7
92125
=============================
93126

src/NHibernate.Test/Async/BulkManipulation/HQLBulkOperations.cs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,5 +43,21 @@ public async Task SimpleDeleteAsync()
4343
await (tx.CommitAsync());
4444
}
4545
}
46+
47+
[Test]
48+
public async Task InsertFromSelectWithMultipleAssociationsAsync()
49+
{
50+
Assume.That(TestDialect.NativeGeneratorSupportsBulkInsertion,
51+
"The dialect does not support a native generator compatible with bulk insertion.");
52+
53+
using var s = OpenSession();
54+
using var tx = s.BeginTransaction();
55+
56+
await (s.CreateQuery("insert into Enrolment (Course, Student)" +
57+
" select e.Course, e.Student from Enrolment e")
58+
.ExecuteUpdateAsync());
59+
60+
await (tx.CommitAsync());
61+
}
4662
}
47-
}
63+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
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 NUnit.Framework;
13+
14+
namespace NHibernate.Test.NHSpecificTest.GH3465
15+
{
16+
using System.Threading.Tasks;
17+
[TestFixture]
18+
public class FixtureAsync : BugTestCase
19+
{
20+
[Test]
21+
public void ThetaJoinSubQueryAsync()
22+
{
23+
using (var session = OpenSession())
24+
using (session.BeginTransaction())
25+
{
26+
var query = session.CreateQuery("select e.Id from EntityA e where exists (from e.Children b, EntityC c)");
27+
Assert.DoesNotThrowAsync(() => query.ListAsync());
28+
}
29+
}
30+
}
31+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
namespace NHibernate.Test.BulkManipulation
2+
{
3+
public class Course
4+
{
5+
public virtual long CourseId { get; set; }
6+
public virtual string Description { get; set; }
7+
}
8+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
using System;
2+
3+
namespace NHibernate.Test.BulkManipulation
4+
{
5+
[Serializable]
6+
public class Enrolment
7+
{
8+
public virtual long EnrolmentId { get; set; }
9+
public virtual Student Student { get; set; }
10+
public virtual Course Course { get; set; }
11+
}
12+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?xml version="1.0"?>
2+
<hibernate-mapping
3+
xmlns="urn:nhibernate-mapping-2.2"
4+
assembly="NHibernate.Test"
5+
namespace="NHibernate.Test.BulkManipulation">
6+
7+
<class name="Course">
8+
<id name="CourseId">
9+
<generator class="native" />
10+
</id>
11+
<property name="Description" />
12+
</class>
13+
14+
<class name="Student">
15+
<id name="StudentId">
16+
<generator class="native" />
17+
</id>
18+
<property name="Name" />
19+
</class>
20+
21+
<class name="Enrolment">
22+
<id name="EnrolmentId">
23+
<generator class="native" />
24+
</id>
25+
<many-to-one name="Student" column="StudentId" class="Student" />
26+
<many-to-one name="Course" column="CourseId" class="Course" />
27+
</class>
28+
29+
</hibernate-mapping>

src/NHibernate.Test/BulkManipulation/HQLBulkOperations.cs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,21 @@ public void SimpleDelete()
3232
tx.Commit();
3333
}
3434
}
35+
36+
[Test]
37+
public void InsertFromSelectWithMultipleAssociations()
38+
{
39+
Assume.That(TestDialect.NativeGeneratorSupportsBulkInsertion,
40+
"The dialect does not support a native generator compatible with bulk insertion.");
41+
42+
using var s = OpenSession();
43+
using var tx = s.BeginTransaction();
44+
45+
s.CreateQuery("insert into Enrolment (Course, Student)" +
46+
" select e.Course, e.Student from Enrolment e")
47+
.ExecuteUpdate();
48+
49+
tx.Commit();
50+
}
3551
}
36-
}
52+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
namespace NHibernate.Test.BulkManipulation
2+
{
3+
public class Student
4+
{
5+
public virtual long StudentId { get; set; }
6+
public virtual string Name { get; set; }
7+
}
8+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
using System;
2+
using System.Collections.Generic;
3+
4+
namespace NHibernate.Test.NHSpecificTest.GH3465
5+
{
6+
class EntityA
7+
{
8+
public virtual Guid Id { get; set; }
9+
public virtual ISet<EntityB> Children { get; set; }
10+
}
11+
class EntityB
12+
{
13+
public virtual Guid Id { get; set; }
14+
public virtual EntityA Parent { get; set; }
15+
}
16+
class EntityC
17+
{
18+
public virtual Guid Id { get; set; }
19+
}
20+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
using System.Linq;
2+
using NUnit.Framework;
3+
4+
namespace NHibernate.Test.NHSpecificTest.GH3465
5+
{
6+
[TestFixture]
7+
public class Fixture : BugTestCase
8+
{
9+
[Test]
10+
public void ThetaJoinSubQuery()
11+
{
12+
using (var session = OpenSession())
13+
using (session.BeginTransaction())
14+
{
15+
var query = session.CreateQuery("select e.Id from EntityA e where exists (from e.Children b, EntityC c)");
16+
Assert.DoesNotThrow(() => query.List());
17+
}
18+
}
19+
}
20+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="NHibernate.Test"
3+
namespace="NHibernate.Test.NHSpecificTest.GH3465">
4+
<class name="EntityA">
5+
<id name="Id" generator="guid.comb" />
6+
<set name="Children" cascade="all-delete-orphan" inverse="true">
7+
<key column="EntityAId" />
8+
<one-to-many class="EntityB" />
9+
</set>
10+
</class>
11+
<class name="EntityB">
12+
<id name="Id" generator="guid.comb" />
13+
<many-to-one name="Parent" column="EntityAId" class="EntityA" not-null="true" />
14+
</class>
15+
<class name="EntityC">
16+
<id name="Id" generator="guid.comb" />
17+
</class>
18+
</hibernate-mapping>

src/NHibernate/Hql/Ast/ANTLR/Tree/FromElement.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -716,7 +716,7 @@ public void SetOrigin(FromElement origin, bool manyToMany)
716716
JoinSequence.SetUseThetaStyle(true);
717717
}
718718
}
719-
else
719+
else if (Walker.CurrentClauseType != HqlSqlWalker.FROM)
720720
{
721721
FromClause.AppendFromElement(this);
722722
}

src/NHibernate/Hql/Ast/ANTLR/Tree/SelectClause.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,7 @@ private void RenderNonScalarIdentifiers(
494494
}
495495

496496
var node = (IASTNode) e;
497-
if (processedElements.Add(fromElement))
497+
if (Walker.IsShallowQuery && node.Type == SqlGenerator.DOT || processedElements.Add(fromElement))
498498
{
499499
combinedFromElements.Add(fromElement);
500500
RenderNonScalarIdentifiers(fromElement, inheritedExpressions.ContainsKey(e) ? null : e, appender);

0 commit comments

Comments
 (0)