Skip to content

Commit 75ed355

Browse files
authored
Merge branch 'master' into dep
2 parents 9681a20 + d6e054f commit 75ed355

File tree

180 files changed

+5796
-1150
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

180 files changed

+5796
-1150
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ of NHibernate (in no particular order):
103103
[Apache Software Foundation]: http://www.apache.org
104104
[JetBrains]: http://www.jetbrains.com
105105
[ReSharper]: http://www.jetbrains.com/resharper
106-
[LinFu]: http://code.google.com/p/linfu
106+
[LinFu]: https://github.com/philiplaureano/LinFu
107107
[article]: http://www.codeproject.com/KB/recipes/sets.aspx
108-
[Relinq]: http://relinq.codeplex.com/
108+
[Relinq]: https://github.com/re-motion/Relinq
109109
[AsyncGenerator]: http://github.com/maca88/AsyncGenerator

releasenotes.txt

Lines changed: 61 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,36 @@
1-
Build 5.3.2
1+
Build 5.3.3
2+
=============================
3+
4+
Release notes - NHibernate - Version 5.3.3
5+
6+
16 issues were resolved in this release.
7+
8+
** Bug
9+
10+
* #2519 Fix parameter caching for Linq provider
11+
* #2515 InvalidCastException for Linq query with subquery
12+
* #2514 Entity with field interceptor are not correctly passed as Linq parameters
13+
* #2512 Linq queries with a condition after a projection on a collection fail
14+
* #2511 Linq Fetch over component after fetching a many-to-one throws exception
15+
* #2508 OnPreUpdateCollection - Passed entity instance X is not of expected type Y
16+
* #2499 Cast operation fails when an enum is mapped as an AnsiString
17+
* #2490 Unnecessary cast in sql with Linq are causing performance issues
18+
* #2488 Fix parameter detection for Equals and CompareTo methods for Linq provider
19+
* #2485 Throw entity not mapped exception for entity join in hql if possible
20+
* #2484 Entity Joins are not polymorphic in hql
21+
* #2476 Hashset add returns true instead of false
22+
* #2474 Fetch all lazy properties when entity is already loaded fails
23+
* #2471 AsQueryable() on collection throws if applied after Where statement
24+
25+
** Task
26+
27+
* #2482 Add missing possible breaking changes for #2010
28+
* #2527 Release 5.3.3
29+
30+
As part of releasing 5.3.3, two missing 5.3.0 possible breaking changes have been added, about
31+
uninitialized extra lazy collections and SQLite schema validation. See 5.3.0 possible breaking changes.
32+
33+
Build 5.3.2
234
=============================
335

436
Release notes - NHibernate - Version 5.3.2
@@ -69,12 +101,40 @@ Release notes - NHibernate - Version 5.3.0
69101
stored as `REAL` instead of `NUMERIC`. Both are binary floating point types, excepted that `NUMERIC`
70102
stores integral values as `INTEGER`. This change may cause big integral decimal values to lose more
71103
precision in SQLite.
104+
* SQLite: non supported SQL type names previously used by NHibernate, resulting in unexpected actual typing,
105+
have been fixed. This causes databases generated by a previous NHibernate version to fail schema validation
106+
by 5.3 or higher versions. See #2507 for more information.
72107
* Custom dialects used for databases that do not support cross join will have to override
73108
`SupportsCrossJoin` property and set it to `false`.
74109
* `VisitorParameters.ConstantToParameterMap` may contain the same parameter for multiple constant
75110
expressions.
76111
* `ICache` caches yielded by the session factory will be `CacheBase` wrappers around the cache actually
77112
provided by the cache provider, if it was not deriving from `CacheBase`.
113+
* Calling `IList.RemoveAt` or `IList<>.RemoveAt` on an uninitialized list with a negative number
114+
will now throw an `ArgumentOutOfRangeException`.
115+
* Calling `IList.RemoveAt` or `IList<>.RemoveAt` on an uninitialized list mapped as `lazy="extra"`
116+
with a number that is equal or higher that the current collection size will now throw an
117+
`ArgumentOutOfRangeException`.
118+
* Calling `IList.Insert` or `IList<>.Insert` on an uninitialized list with a negative number will
119+
now throw an `ArgumentOutOfRangeException`.
120+
* Calling `IList.Insert` or `IList<>.Insert` on an uninitialized list mapped as `lazy="extra"`
121+
with a number that is higher that the current collection size will now throw an
122+
`ArgumentOutOfRangeException`.
123+
* Getting or setting a value with `IList.this[int index]` or `IList<>.this[int index]` on an uninitialized
124+
list with a negative number will now throw an `ArgumentOutOfRangeException`.
125+
* Setting a value with `IList.this[int index]` or `IList<>.this[int index]` on an uninitialized list
126+
mapped as `lazy="extra"` with a number that is equal or higher that the current collection size will now
127+
throw an `ArgumentOutOfRangeException`.
128+
* Calling `IDictionary<,>.Add` or `ICollection<>.Add` on an uninitialized map mapped as `lazy="extra"` with
129+
a key that already exists will now throw an `ArgumentException`.
130+
* Calling `IDictionary<,>.Remove` or `ICollection<>.Remove` on an uninitialized map mapped as `lazy="extra"`
131+
with a key that does not exist will now return false.
132+
* Map dirtiness is now evaluated by `EqualityComparer<TValue>.Default` when setting an existing key value
133+
with `IDictionary<,>.this[]` on an initialized map.
134+
* Calling `ISet<>.Add` on an uninitialized set mapped as `lazy="extra"` with a transient element that
135+
already exists in the set will now return false.
136+
* Calling `ISet<>.Add` or `ICollection<>.Add` on an uninitialized set mapped as `lazy="true"` with a
137+
transient element that does not override `Equals` method will not initialize the collection.
78138

79139
** Bug
80140

src/AsyncGenerator.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,7 @@ methodRules:
287287
- containingType: NHibernate.Linq.DmlExtensionMethods
288288
- containingType: NHibernate.Linq.InsertBuilder<TSource, TTarget>
289289
- containingType: NHibernate.Linq.UpdateBuilder<TSource>
290+
- containingType: NHibernate.Multi.IQueryBatch
290291
name: PubliclyExposedType
291292
- filters:
292293
- hasAttributeName: ObsoleteAttribute

src/NHibernate.DomainModel/Northwind/Entities/AnotherEntityRequired.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ public class AnotherEntityRequired
2222

2323
public virtual ISet<AnotherEntity> RelatedItems { get; set; } = new HashSet<AnotherEntity>();
2424

25+
public virtual ISet<AnotherEntityRequired> RequiredRelatedItems { get; set; } = new HashSet<AnotherEntityRequired>();
26+
2527
public virtual bool? NullableBool { get; set; }
2628
}
2729

src/NHibernate.DomainModel/Northwind/Entities/Northwind.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,11 @@ public IQueryable<User> Users
6969
get { return _session.Query<User>(); }
7070
}
7171

72+
public IQueryable<NumericEntity> NumericEntities
73+
{
74+
get { return _session.Query<NumericEntity>(); }
75+
}
76+
7277
public IQueryable<DynamicUser> DynamicUsers
7378
{
7479
get { return _session.Query<DynamicUser>(); }
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
namespace NHibernate.DomainModel.Northwind.Entities
2+
{
3+
public class NumericEntity
4+
{
5+
public virtual short Short { get; set; }
6+
7+
public virtual short? NullableShort { get; set; }
8+
9+
public virtual int Integer { get; set; }
10+
11+
public virtual int? NullableInteger { get; set; }
12+
13+
public virtual long Long { get; set; }
14+
15+
public virtual long? NullableLong { get; set; }
16+
17+
public virtual decimal Decimal { get; set; }
18+
19+
public virtual decimal? NullableDecimal { get; set; }
20+
21+
public virtual float Single { get; set; }
22+
23+
public virtual float? NullableSingle { get; set; }
24+
25+
public virtual double Double { get; set; }
26+
27+
public virtual double? NullableDouble { get; set; }
28+
}
29+
}

src/NHibernate.DomainModel/Northwind/Mappings/AnotherEntityRequired.hbm.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,9 @@
1919
<key column="Id"/>
2020
<one-to-many class="AnotherEntity"/>
2121
</set>
22+
<set name="RequiredRelatedItems" lazy="true" inverse="true">
23+
<key column="Id"/>
24+
<one-to-many class="AnotherEntityRequired"/>
25+
</set>
2226
</class>
2327
</hibernate-mapping>
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" namespace="NHibernate.DomainModel.Northwind.Entities" assembly="NHibernate.DomainModel">
3+
<class name="NumericEntity">
4+
<id name="Short">
5+
<generator class="assigned" />
6+
</id>
7+
8+
<property name="NullableShort" />
9+
<property name="Integer" not-null="true" column="`Integer`" />
10+
<property name="NullableInteger" />
11+
<property name="Long" not-null="true" column="`Long`" />
12+
<property name="NullableLong" />
13+
<property name="Decimal" not-null="true" column="`Decimal`" />
14+
<property name="NullableDecimal" />
15+
<property name="Single" not-null="true" column="`Single`" />
16+
<property name="NullableSingle" />
17+
<property name="Double" not-null="true" column="`Double`" />
18+
<property name="NullableDouble" />
19+
</class>
20+
</hibernate-mapping>

src/NHibernate.Test/Async/CacheTest/BatchableCacheFixture.cs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1112,7 +1112,7 @@ public async Task QueryCacheTestAsync()
11121112

11131113
using (var t = s.BeginTransaction())
11141114
{
1115-
await (queries.ExecuteAsync(CancellationToken.None));
1115+
await (queries.ExecuteAsync());
11161116
await (t.CommitAsync());
11171117
}
11181118

@@ -1127,24 +1127,24 @@ public async Task QueryCacheTestAsync()
11271127
// Run a second time, to test the query cache
11281128
using (var t = s.BeginTransaction())
11291129
{
1130-
await (queries.ExecuteAsync(CancellationToken.None));
1130+
await (queries.ExecuteAsync());
11311131
await (t.CommitAsync());
11321132
}
11331133

11341134
Assert.That(
1135-
await (queries.GetResultAsync<ReadOnly>(0, CancellationToken.None)),
1135+
await (queries.GetResultAsync<ReadOnly>(0)),
11361136
Has.Count.EqualTo(1).And.One.Property(nameof(ReadOnly.Name)).EqualTo(name1), "q1");
11371137
Assert.That(
1138-
await (queries.GetResultAsync<ReadOnly>(1, CancellationToken.None)),
1138+
await (queries.GetResultAsync<ReadOnly>(1)),
11391139
Has.Count.EqualTo(1).And.One.Property(nameof(ReadOnly.Name)).EqualTo(name2), "q2");
11401140
Assert.That(
1141-
await (queries.GetResultAsync<ReadWrite>(2, CancellationToken.None)),
1141+
await (queries.GetResultAsync<ReadWrite>(2)),
11421142
Has.Count.EqualTo(1).And.One.Property(nameof(ReadWrite.Name)).EqualTo(name3), "q3");
11431143
Assert.That(
1144-
await (queries.GetResultAsync<ReadWrite>(3, CancellationToken.None)),
1144+
await (queries.GetResultAsync<ReadWrite>(3)),
11451145
Has.Count.EqualTo(1).And.One.Property(nameof(ReadWrite.Name)).EqualTo(name4), "q4");
11461146
Assert.That(
1147-
await (queries.GetResultAsync<ReadOnly>(4, CancellationToken.None)),
1147+
await (queries.GetResultAsync<ReadOnly>(4)),
11481148
Has.Count.EqualTo(1).And.One.Property(nameof(ReadOnly.Name)).EqualTo(name5), "q5");
11491149

11501150
Assert.That(cache.GetMultipleCalls, Has.Count.EqualTo(2), "cache GetMany secondExecution");
@@ -1174,24 +1174,24 @@ public async Task QueryCacheTestAsync()
11741174
// Run a third time, to re-test the query cache
11751175
using (var t = s.BeginTransaction())
11761176
{
1177-
await (queries.ExecuteAsync(CancellationToken.None));
1177+
await (queries.ExecuteAsync());
11781178
await (t.CommitAsync());
11791179
}
11801180

11811181
Assert.That(
1182-
await (queries.GetResultAsync<ReadOnly>(0, CancellationToken.None)),
1182+
await (queries.GetResultAsync<ReadOnly>(0)),
11831183
Has.Count.EqualTo(1).And.One.Property(nameof(ReadOnly.Name)).EqualTo(name1), "q1 after update");
11841184
Assert.That(
1185-
await (queries.GetResultAsync<ReadOnly>(1, CancellationToken.None)),
1185+
await (queries.GetResultAsync<ReadOnly>(1)),
11861186
Has.Count.EqualTo(1).And.One.Property(nameof(ReadOnly.Name)).EqualTo(name2), "q2 after update");
11871187
Assert.That(
1188-
await (queries.GetResultAsync<ReadWrite>(2, CancellationToken.None)),
1188+
await (queries.GetResultAsync<ReadWrite>(2)),
11891189
Has.Count.EqualTo(0), "q3 after update");
11901190
Assert.That(
1191-
await (queries.GetResultAsync<ReadWrite>(3, CancellationToken.None)),
1191+
await (queries.GetResultAsync<ReadWrite>(3)),
11921192
Has.Count.EqualTo(1).And.One.Property(nameof(ReadWrite.Name)).EqualTo(name4), "q4 after update");
11931193
Assert.That(
1194-
await (queries.GetResultAsync<ReadOnly>(4, CancellationToken.None)),
1194+
await (queries.GetResultAsync<ReadOnly>(4)),
11951195
Has.Count.EqualTo(1).And.One.Property(nameof(ReadOnly.Name)).EqualTo(name5), "q5 after update");
11961196

11971197
Assert.That(cache.GetMultipleCalls, Has.Count.EqualTo(3), "cache GetMany thirdExecution");

src/NHibernate.Test/Async/Criteria/CriteriaQueryTest.cs

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
using System;
1212
using System.Collections;
1313
using System.Collections.Generic;
14+
using System.Linq;
1415
using NHibernate.Dialect;
1516
using NHibernate.Criterion;
1617
using NHibernate.Linq;
@@ -2085,6 +2086,64 @@ public async Task RestrictionOnSubclassCollectionAsync()
20852086
s.Close();
20862087
}
20872088

2089+
//NH-2239 (GH-1075) - Wrong OrderBy in generated SQL
2090+
[Test]
2091+
public async Task OrderByAndOrderedCollectionAsync()
2092+
{
2093+
var reptile1 = new Reptile { SerialNumber = "9" };
2094+
var reptile2 = new Reptile { SerialNumber = "8" };
2095+
var reptile3 = new Reptile { SerialNumber = "7" };
2096+
var reptile4 = new Reptile { SerialNumber = "6" };
2097+
var reptile5 = new Reptile { SerialNumber = "5" };
2098+
2099+
using (var s = OpenSession())
2100+
using (var t = s.BeginTransaction())
2101+
{
2102+
await (s.SaveAsync(reptile5));
2103+
await (s.SaveAsync(reptile1));
2104+
await (s.SaveAsync(reptile2));
2105+
await (s.SaveAsync(reptile3));
2106+
await (s.SaveAsync(reptile4));
2107+
2108+
reptile1.AddOffspring(reptile4);
2109+
reptile1.AddOffspring(reptile2);
2110+
reptile4.Father = reptile3;
2111+
reptile2.Father = reptile4;
2112+
reptile1.Father = reptile5;
2113+
reptile3.AddOffspring(reptile1);
2114+
2115+
await (t.CommitAsync());
2116+
}
2117+
2118+
using(var s = OpenSession())
2119+
{
2120+
var list = await (s.CreateCriteria(typeof(Reptile))
2121+
.Fetch(SelectMode.Fetch, "offspring")
2122+
.AddOrder(Order.Asc("serialNumber"))
2123+
.SetResultTransformer(Transformers.DistinctRootEntity)
2124+
.ListAsync<Reptile>());
2125+
2126+
var expectedList = list.OrderBy(x => x.SerialNumber).ToList();
2127+
2128+
Assert.That(list.Count, Is.EqualTo(5));
2129+
CollectionAssert.AreEqual(expectedList, list);
2130+
2131+
var mother = expectedList.Last();
2132+
Assert.That(NHibernateUtil.IsInitialized(mother.Offspring), Is.True);
2133+
2134+
var expectedAssociationList = mother.Offspring.OrderBy(r => r.Father.Id).ToList();
2135+
Assert.That(expectedAssociationList.Count, Is.EqualTo(2));
2136+
CollectionAssert.AreEqual(expectedAssociationList, mother.Offspring);
2137+
}
2138+
2139+
using (var s = OpenSession())
2140+
using (var t = s.BeginTransaction())
2141+
{
2142+
await (s.DeleteAsync("from Reptile"));
2143+
await (t.CommitAsync());
2144+
}
2145+
}
2146+
20882147
[Test]
20892148
public async Task ClassPropertyAsync()
20902149
{
@@ -2441,6 +2500,22 @@ public async Task SubcriteriaJoinTypesAsync()
24412500
session.Close();
24422501
}
24432502

2503+
public class NotMappedEntity
2504+
{
2505+
public virtual int Id { get; set; }
2506+
public virtual string Name { get; set; }
2507+
}
2508+
2509+
[Test]
2510+
public void CriteriaOnNotMappedEntityAsync()
2511+
{
2512+
using (ISession session = OpenSession())
2513+
{
2514+
Assert.ThrowsAsync<QueryException>(
2515+
() => session.CreateCriteria(typeof(NotMappedEntity)).ListAsync());
2516+
}
2517+
}
2518+
24442519
[Test]
24452520
public void TypeMismatchAsync()
24462521
{

src/NHibernate.Test/Async/Criteria/Lambda/IntegrationFixture.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -428,8 +428,8 @@ public async Task MultiQueryAsync()
428428
.Add("page", query)
429429
.Add<int>("count", query.ToRowCountQuery());
430430

431-
var pageResults = await (multiQuery.GetResultAsync<Person>("page", CancellationToken.None));
432-
var countResults = await (multiQuery.GetResultAsync<int>("count", CancellationToken.None));
431+
var pageResults = await (multiQuery.GetResultAsync<Person>("page"));
432+
var countResults = await (multiQuery.GetResultAsync<int>("count"));
433433

434434
Assert.That(pageResults.Count, Is.EqualTo(1));
435435
Assert.That(pageResults[0].Name, Is.EqualTo("Name 3"));
@@ -451,8 +451,8 @@ public async Task MultiQueryAsync()
451451
.Add("page", query)
452452
.Add<int>("count", query.ToRowCountQuery());
453453

454-
var pageResults = await (multiCriteria.GetResultAsync<Person>("page", CancellationToken.None));
455-
var countResults = await (multiCriteria.GetResultAsync<int>("count", CancellationToken.None));
454+
var pageResults = await (multiCriteria.GetResultAsync<Person>("page"));
455+
var countResults = await (multiCriteria.GetResultAsync<int>("count"));
456456

457457
Assert.That(pageResults.Count, Is.EqualTo(1));
458458
Assert.That(pageResults[0].Name, Is.EqualTo("Name 3"));

0 commit comments

Comments
 (0)