Skip to content

Commit

Permalink
Merge 5.4.8 into 5.5.x
Browse files Browse the repository at this point in the history
  • Loading branch information
fredericDelaporte committed Mar 26, 2024
2 parents c1c8627 + b3256e7 commit 860fa10
Show file tree
Hide file tree
Showing 8 changed files with 108 additions and 3 deletions.
16 changes: 16 additions & 0 deletions releasenotes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,22 @@ Release notes - NHibernate - Version 5.5.0
* #3412 Revive hql ParsingFixture


Build 5.4.8
=============================

Release notes - NHibernate - Version 5.4.8

2 issues were resolved in this release.

** Bug

* #3489 Inserting multiple associations of the same entity fails

** Task

* #3507 Release 5.4.8


Build 5.4.7
=============================

Expand Down
18 changes: 17 additions & 1 deletion src/NHibernate.Test/Async/BulkManipulation/HQLBulkOperations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,21 @@ public async Task SimpleDeleteAsync()
await (tx.CommitAsync());
}
}

[Test]
public async Task InsertFromSelectWithMultipleAssociationsAsync()
{
Assume.That(TestDialect.NativeGeneratorSupportsBulkInsertion,
"The dialect does not support a native generator compatible with bulk insertion.");

using var s = OpenSession();
using var tx = s.BeginTransaction();

await (s.CreateQuery("insert into Enrolment (Course, Student)" +
" select e.Course, e.Student from Enrolment e")
.ExecuteUpdateAsync());

await (tx.CommitAsync());
}
}
}
}
8 changes: 8 additions & 0 deletions src/NHibernate.Test/BulkManipulation/Course.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace NHibernate.Test.BulkManipulation
{
public class Course
{
public virtual long CourseId { get; set; }
public virtual string Description { get; set; }
}
}
12 changes: 12 additions & 0 deletions src/NHibernate.Test/BulkManipulation/Enrolment.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using System;

namespace NHibernate.Test.BulkManipulation
{
[Serializable]
public class Enrolment
{
public virtual long EnrolmentId { get; set; }
public virtual Student Student { get; set; }
public virtual Course Course { get; set; }
}
}
29 changes: 29 additions & 0 deletions src/NHibernate.Test/BulkManipulation/Enrolment.hbm.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?xml version="1.0"?>
<hibernate-mapping
xmlns="urn:nhibernate-mapping-2.2"
assembly="NHibernate.Test"
namespace="NHibernate.Test.BulkManipulation">

<class name="Course">
<id name="CourseId">
<generator class="native" />
</id>
<property name="Description" />
</class>

<class name="Student">
<id name="StudentId">
<generator class="native" />
</id>
<property name="Name" />
</class>

<class name="Enrolment">
<id name="EnrolmentId">
<generator class="native" />
</id>
<many-to-one name="Student" column="StudentId" class="Student" />
<many-to-one name="Course" column="CourseId" class="Course" />
</class>

</hibernate-mapping>
18 changes: 17 additions & 1 deletion src/NHibernate.Test/BulkManipulation/HQLBulkOperations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,21 @@ public void SimpleDelete()
tx.Commit();
}
}

[Test]
public void InsertFromSelectWithMultipleAssociations()
{
Assume.That(TestDialect.NativeGeneratorSupportsBulkInsertion,
"The dialect does not support a native generator compatible with bulk insertion.");

using var s = OpenSession();
using var tx = s.BeginTransaction();

s.CreateQuery("insert into Enrolment (Course, Student)" +
" select e.Course, e.Student from Enrolment e")
.ExecuteUpdate();

tx.Commit();
}
}
}
}
8 changes: 8 additions & 0 deletions src/NHibernate.Test/BulkManipulation/Student.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace NHibernate.Test.BulkManipulation
{
public class Student
{
public virtual long StudentId { get; set; }
public virtual string Name { get; set; }
}
}
2 changes: 1 addition & 1 deletion src/NHibernate/Hql/Ast/ANTLR/Tree/SelectClause.cs
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ private void RenderNonScalarIdentifiers(
}

var node = (IASTNode) e;
if (processedElements.Add(fromElement))
if (Walker.IsShallowQuery && node.Type == SqlGenerator.DOT || processedElements.Add(fromElement))
{
combinedFromElements.Add(fromElement);
RenderNonScalarIdentifiers(fromElement, inheritedExpressions.ContainsKey(e) ? null : e, appender);
Expand Down

0 comments on commit 860fa10

Please sign in to comment.