Skip to content

Commit d94b00b

Browse files
authored
Merge branch 'master' into NH-3606
2 parents ef52c00 + b8af99f commit d94b00b

File tree

105 files changed

+2560
-1087
lines changed

Some content is hidden

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

105 files changed

+2560
-1087
lines changed

build-common/NHibernate.props

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,8 @@
2121
<PackageLicenseUrl>https://raw.githubusercontent.com/nhibernate/nhibernate-core/master/LICENSE.txt</PackageLicenseUrl>
2222
<RepositoryUrl>https://github.com/nhibernate/nhibernate-core.git</RepositoryUrl>
2323
<RepositoryType>git</RepositoryType>
24+
25+
<TreatWarningsAsErrors>True</TreatWarningsAsErrors>
26+
<TreatSpecificWarningsAsErrors />
2427
</PropertyGroup>
2528
</Project>

doc/reference/modules/basic_mapping.xml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2633,7 +2633,7 @@
26332633
types, <literal>System.Object</literal> types, and <literal>System.Object</literal> types for large objects. Just like
26342634
Columns for System.ValueType types can handle <literal>null</literal> values only if the entity property is properly
26352635
typed with a <literal>Nullable&lt;T&gt;</literal>. Otherwise <literal>null</literal> will be replaced by the default
2636-
value for the type when reading, and when be overwritten by it when persisting the entity, potentially leading to
2636+
value for the type when reading, and then will be overwritten by it when persisting the entity, potentially leading to
26372637
phantom updates.
26382638
</para>
26392639
<table>
@@ -3025,6 +3025,12 @@
30253025
<literal>NHibernate.Type.TypeFactory</literal>.
30263026
</para>
30273027

3028+
<para>
3029+
Default NHibernate types used when no <literal>type</literal> attribute is specified can be overridden by using
3030+
the <literal>NHibernate.Type.TypeFactory.RegisterType</literal> static method before configuring and building
3031+
session factories.
3032+
</para>
3033+
30283034
</sect2>
30293035

30303036
<sect2 id="mapping-types-custom">

lib/teamcity/oracle/oracle_installation.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,10 @@ This is needed because NHibernate test uses the managed driver NuGet package, bu
4141
version needs to be removed from the GAC. Read more on https://stackoverflow.com/a/35176586/1178314.
4242
Not doing this may notably cause failures in distributed transaction tests.
4343

44+
Adjust the connection string for the tests:
45+
The tests involve creating and dropping many tables, sometimes with the same names but different data
46+
types. This does not play well with Oracle meta data pooling, which needs to be disabled.
47+
Add into your ODP.NET connection string:
48+
Metadata Pooling=false;Self Tuning=false;
49+
4450
Please note that some tests are dependent on the machine locales, and may fail if they are not English.

src/.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@
2222
*.scc
2323
*.tokens
2424
[Bb]in
25-
[Db]ebug*/
25+
[Db]ebug/
2626
obj/
27-
[Rr]elease*/
27+
[Rr]elease/
2828
*resharper*
2929
_ReSharper*/
3030
[Tt]est[Rr]esult*
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
using System;
2+
using System.Linq;
3+
using System.Linq.Expressions;
4+
5+
// Simulates compiler-generated, non-namespaced anonymous type with one property
6+
internal class AnonymousType1<TProp1>
7+
{
8+
public TProp1 Prop1 { get; set; }
9+
}
10+
11+
namespace NHibernate.DomainModel.NHSpecific
12+
{
13+
public class AnonymousTypeQueryExpressionProviderFromNHibernateDomainModelAssembly
14+
{
15+
private readonly TypedQueryExpressionProvider<AnonymousType1<string>> _provider
16+
= new TypedQueryExpressionProvider<AnonymousType1<string>>();
17+
18+
public System.Type GetAnonymousType()
19+
{
20+
return _provider.GetSuppliedType();
21+
}
22+
23+
public Expression GetExpressionOfMethodCall()
24+
{
25+
return _provider.GetExpressionOfMethodCall();
26+
}
27+
28+
public Expression GetExpressionOfNew()
29+
{
30+
return _provider.GetExpressionOfNew();
31+
}
32+
33+
public Expression GetExpressionOfTypeBinary()
34+
{
35+
return _provider.GetExpressionOfTypeBinary();
36+
}
37+
}
38+
39+
public class TypedQueryExpressionProvider<T> where T : new ()
40+
{
41+
public System.Type GetSuppliedType()
42+
{
43+
return typeof(T);
44+
}
45+
46+
public Expression GetExpressionOfMethodCall()
47+
{
48+
Expression<Func<object>> exp = () =>
49+
Enumerable.Empty<object>().Select(o => (T)o).ToList();
50+
51+
return exp;
52+
}
53+
54+
public Expression GetExpressionOfNew()
55+
{
56+
// adds .GetHashCode to make sure the .ToList is always of same generic type
57+
// so that the only variable part is the 'new T()'
58+
Expression<Func<object>> exp = () =>
59+
Enumerable.Empty<object>().Select(o => new T().GetHashCode()).ToList();
60+
61+
return exp;
62+
}
63+
64+
public Expression GetExpressionOfTypeBinary()
65+
{
66+
Expression<Func<object>> exp = () =>
67+
Enumerable.Empty<object>().Select(o => o is T).ToList();
68+
69+
return exp;
70+
}
71+
}
72+
}

src/NHibernate.DomainModel/NHibernate.DomainModel.csproj

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,6 @@
66
<IsTestProject>true</IsTestProject>
77
<NoWarn>$(NoWarn);3001;3002;3003;3005</NoWarn>
88
</PropertyGroup>
9-
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
10-
<TreatWarningsAsErrors>True</TreatWarningsAsErrors>
11-
<TreatSpecificWarningsAsErrors />
12-
</PropertyGroup>
139
<ItemGroup>
1410
<None Remove="**\*.hbm.xml" />
1511
</ItemGroup>

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

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ namespace NHibernate.Test.Criteria
2525
[TestFixture]
2626
public class EntityProjectionsTestAsync : TestCaseMappingByCode
2727
{
28+
private const string customEntityName = "CustomEntityName";
2829
private EntityWithCompositeId _entityWithCompositeId;
30+
private EntityCustomEntityName _entityWithCustomEntityName;
2931

3032
protected override HbmMapping GetMappings()
3133
{
@@ -76,6 +78,16 @@ protected override HbmMapping GetMappings()
7678

7779
rc.Property(e => e.Name);
7880
});
81+
82+
mapper.Class<EntityCustomEntityName>(
83+
rc =>
84+
{
85+
rc.EntityName(customEntityName);
86+
87+
rc.Id(x => x.Id, m => m.Generator(Generators.GuidComb));
88+
rc.Property(x => x.Name);
89+
});
90+
7991
return mapper.CompileMappingForAllExplicitlyAddedEntities();
8092
}
8193

@@ -117,6 +129,11 @@ protected override void OnSetUp()
117129
}
118130
};
119131

132+
_entityWithCustomEntityName = new EntityCustomEntityName()
133+
{
134+
Name = "EntityCustomEntityName"
135+
};
136+
120137
_entityWithCompositeId = new EntityWithCompositeId
121138
{
122139
Key = new CompositeKey
@@ -132,6 +149,7 @@ protected override void OnSetUp()
132149
session.Save(parent.SameTypeChild);
133150
session.Save(parent);
134151
session.Save(_entityWithCompositeId);
152+
session.Save(customEntityName, _entityWithCustomEntityName);
135153

136154
session.Flush();
137155
transaction.Commit();
@@ -459,5 +477,22 @@ public async Task EntityProjectionForCompositeKeyLazyAsync()
459477
Assert.That(NHibernateUtil.IsInitialized(composite), Is.False, "Object must be lazy loaded.");
460478
}
461479
}
480+
481+
[Test]
482+
public async Task EntityProjectionForCustomEntityNameAsync()
483+
{
484+
using (var session = OpenSession())
485+
{
486+
var entity = await (session
487+
.QueryOver<EntityCustomEntityName>(customEntityName)
488+
.Select(Projections.RootEntity())
489+
.Take(1).SingleOrDefaultAsync());
490+
491+
Assert.That(entity, Is.Not.Null);
492+
Assert.That(NHibernateUtil.IsInitialized(entity), Is.True, "Object must be initialized.");
493+
Assert.That(entity.Id, Is.EqualTo(_entityWithCustomEntityName.Id));
494+
Assert.That(entity.Name, Is.EqualTo(_entityWithCustomEntityName.Name));
495+
}
496+
}
462497
}
463498
}

0 commit comments

Comments
 (0)