Skip to content

Commit ffea30d

Browse files
committed
Merge branch '4.0.x'
2 parents 2becb5b + 5e3f957 commit ffea30d

File tree

52 files changed

+24490
-23561
lines changed

Some content is hidden

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

52 files changed

+24490
-23561
lines changed

build-common/common.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
effectively SP0).
6161
-->
6262

63-
<property name="project.version" value="4.0.1.GA" overwrite="false" />
63+
<property name="project.version" value="4.0.2.GA" overwrite="false" />
6464

6565
<!-- This version number should be changed if, but only if, there are incompatible
6666
changes compared to the previous version. -->

doc/reference/modules/performance.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1149,7 +1149,7 @@ sessionFactory.EvictCollection("Eg.Cat.Kittens"); //evict all kitten collections
11491149
</para>
11501150

11511151
<para>
1152-
one-shot-delete apply to collections mapped <literal>inverse="true"</literal>.
1152+
Of course, one-shot-delete does not apply to collections mapped <literal>inverse="true"</literal>.
11531153
</para>
11541154

11551155
</sect2>

lib/teamcity/firebird/NHibernate.Test.last-results.xml

Lines changed: 349 additions & 280 deletions
Large diffs are not rendered by default.

lib/teamcity/mysql/NHibernate.Test.last-results.xml

Lines changed: 294 additions & 88 deletions
Large diffs are not rendered by default.

lib/teamcity/oracle/NHibernate.Test.last-results.xml

Lines changed: 1833 additions & 1055 deletions
Large diffs are not rendered by default.

lib/teamcity/sqlServerCe/NHibernate.Test.last-results.xml

Lines changed: 5031 additions & 6174 deletions
Large diffs are not rendered by default.

lib/teamcity/sqlServerOdbc/NHibernate.Test.last-results.xml

Lines changed: 16098 additions & 15853 deletions
Large diffs are not rendered by default.

releasenotes.txt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
1+
2+
Build 4.0.2.GA
3+
=============================
4+
5+
** Bug
6+
* [NH-2779] - Session.Get() can throw InvalidCastException when log-level is set to DEBUG
7+
* [NH-2782] - Linq: selecting into a new array doesn't work
8+
* [NH-2831] - NH cannot load mapping assembly from GAC
9+
* [NH-3049] - Mapping by code to Field not working
10+
* [NH-3222] - NHibernate Futures passes empty tuples to ResultSetTransformer
11+
* [NH-3650] - ComponentAsId<T> used more than once, cache first mapping and produces subsequently a sql select wrong
12+
* [NH-3709] - Fix Reference to One Shot Delete and Inverse Collections
13+
* [NH-3710] - Use of SetLockMode with DetachedCriteria causes null reference exception
14+
15+
** Task
16+
* [NH-3697] - Ignore Firebird in NHSpecificTest.NH1981
17+
* [NH-3698] - NHSpecificTest.NH1989 fails for some drivers
18+
19+
120
Build 4.0.1.GA
221
=============================
322

src/NHibernate.Test/App.config

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,5 +103,13 @@
103103
</log4net>
104104

105105
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup>
106+
<runtime>
107+
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
108+
<dependentAssembly>
109+
<assemblyIdentity name="nunit.framework" publicKeyToken="96d09a1eb7f44a77" culture="neutral"/>
110+
<bindingRedirect oldVersion="0.0.0.0-2.6.1.12217" newVersion="2.6.1.12217"/>
111+
</dependentAssembly>
112+
</assemblyBinding>
113+
</runtime>
106114

107115
</configuration>

src/NHibernate.Test/Criteria/CriteriaQueryTest.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2983,5 +2983,27 @@ public void IgnoreCase()
29832983
t.Commit();
29842984
}
29852985
}
2986+
2987+
[Test]
2988+
public void CanSetLockModeOnDetachedCriteria()
2989+
{
2990+
//NH-3710
2991+
var dc = DetachedCriteria
2992+
.For(typeof(Student))
2993+
.SetLockMode(LockMode.Upgrade);
2994+
2995+
using (var session = OpenSession())
2996+
using (var tx = session.BeginTransaction())
2997+
{
2998+
session.Save(new Student { Name = "Ricardo Peres", StudentNumber = 666, CityState = new CityState("Coimbra", "Portugal") });
2999+
session.Flush();
3000+
3001+
var ec = dc.GetExecutableCriteria(session);
3002+
var countExec = CriteriaTransformer.TransformToRowCount(ec);
3003+
var countRes = countExec.UniqueResult();
3004+
3005+
Assert.AreEqual(countRes, 1);
3006+
}
3007+
}
29863008
}
29873009
}

src/NHibernate.Test/Linq/MethodCallTests.cs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.Collections.Generic;
23
using System.Linq;
34
using NHibernate.DomainModel.Northwind.Entities;
45
using NUnit.Framework;
@@ -100,6 +101,32 @@ public void CanSelectPropertiesFromAssociationsIntoObjectArray()
100101
Assert.That(result.Length, Is.EqualTo(3));
101102
Assert.That(result[1], Is.EqualTo("Admin"));
102103
Assert.That(result[2], Is.EqualTo("output"));
104+
}
105+
106+
[Test(Description = "NH-2782")]
107+
public void CanSelectPropertiesIntoObjectArrayInProperty()
108+
{
109+
var result = db.Users
110+
.Select(u => new { Cells = new object[] { u.Id, u.Name, new object[u.Id] } })
111+
.First();
112+
113+
var cells = result.Cells;
114+
Assert.That(cells.Length, Is.EqualTo(3));
115+
Assert.That(cells[1], Is.EqualTo("ayende"));
116+
Assert.That(cells[2], Is.InstanceOf<object[]>().And.Length.EqualTo(cells[0]));
117+
}
118+
119+
[Test(Description = "NH-2782")]
120+
public void CanSelectPropertiesIntoPropertyListInProperty()
121+
{
122+
var result = db.Users
123+
.Select(u => new { Cells = new List<object> { u.Id, u.Name, new object[u.Id] } })
124+
.First();
125+
126+
var cells = result.Cells;
127+
Assert.That(cells.Count, Is.EqualTo(3));
128+
Assert.That(cells[1], Is.EqualTo("ayende"));
129+
Assert.That(cells[2], Is.InstanceOf<object[]>().And.Length.EqualTo(cells[0]));
103130
}
104131

105132
[Test, Description("NH-2744")]
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
using System.Linq;
2+
using NHibernate.Cfg.MappingSchema;
3+
using NHibernate.Mapping.ByCode;
4+
using NUnit.Framework;
5+
6+
namespace NHibernate.Test.MappingByCode.ExplicitMappingTests
7+
{
8+
[TestFixture]
9+
public class MappingOfInternalMembersOnRootEntity
10+
{
11+
public class MyClass
12+
{
13+
protected internal int _id;
14+
protected internal int _version;
15+
protected internal string _something;
16+
}
17+
18+
[Test]
19+
public void MapClassWithInternalIdAndProperty()
20+
{
21+
var mapper = new ModelMapper();
22+
mapper.Class<MyClass>(ca =>
23+
{
24+
ca.Id(x => x._id, map =>
25+
{
26+
map.Column("MyClassId");
27+
map.Generator(Generators.HighLow, gmap => gmap.Params(new { max_low = 100 }));
28+
});
29+
ca.Version(x => x._version, map => { });
30+
ca.Property(x => x._something, map => map.Length(150));
31+
});
32+
var hbmMapping = mapper.CompileMappingFor(new[] { typeof(MyClass) });
33+
var hbmClass = hbmMapping.RootClasses[0];
34+
Assert.That(hbmClass, Is.Not.Null);
35+
36+
var hbmId = hbmClass.Id;
37+
Assert.That(hbmId, Is.Not.Null);
38+
Assert.That(hbmId.name, Is.EqualTo("_id"));
39+
Assert.That(hbmId.access, Is.EqualTo("field"));
40+
41+
var hbmIdGenerator = hbmId.generator;
42+
Assert.That(hbmIdGenerator, Is.Not.Null);
43+
Assert.That(hbmIdGenerator.@class, Is.EqualTo("hilo"));
44+
Assert.That(hbmIdGenerator.param[0].name, Is.EqualTo("max_low"));
45+
Assert.That(hbmIdGenerator.param[0].GetText(), Is.EqualTo("100"));
46+
47+
var hbmVersion = hbmClass.Version;
48+
Assert.That(hbmVersion, Is.Not.Null);
49+
Assert.That(hbmVersion.name, Is.EqualTo("_version"));
50+
51+
var hbmProperty = hbmClass.Properties.OfType<HbmProperty>().Single();
52+
Assert.That(hbmProperty.name, Is.EqualTo("_something"));
53+
Assert.That(hbmProperty.access, Is.EqualTo("field"));
54+
Assert.That(hbmProperty.length, Is.EqualTo("150"));
55+
}
56+
}
57+
}
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
using System;
2+
using System.Linq;
3+
using NHibernate;
4+
using NHibernate.Cfg.MappingSchema;
5+
using NHibernate.Linq;
6+
using NHibernate.Mapping.ByCode;
7+
using NHibernate.Mapping.ByCode.Conformist;
8+
using NUnit.Framework;
9+
10+
namespace NHibernate.Test.MappingByCode.ExplicitlyDeclaredModelTests
11+
{
12+
public abstract class Parent
13+
{
14+
public virtual ParentId Id { get; set; }
15+
public virtual string Name { get; set; }
16+
public virtual Address Address { get; set; }
17+
}
18+
19+
public class ParentId
20+
{
21+
public string Key1 { get; set; }
22+
public string Key2 { get; set; }
23+
24+
public override bool Equals(object obj)
25+
{
26+
var pk = obj as ParentId;
27+
28+
if (obj == null)
29+
return false;
30+
31+
return (Key1 == pk.Key1 && Key2 == pk.Key2);
32+
}
33+
34+
public override int GetHashCode()
35+
{
36+
return (Key1 + "|" + Key2).GetHashCode();
37+
}
38+
}
39+
40+
public class Child1 : Parent
41+
{
42+
}
43+
44+
public class Child2 : Parent
45+
{
46+
}
47+
48+
class Child1Map : ClassMapping<Child1>
49+
{
50+
public Child1Map()
51+
{
52+
Table("Child1");
53+
54+
ComponentAsId<ParentId>(x => x.Id, pk =>
55+
{
56+
pk.Property(x => x.Key1, x => x.Column("key1"));
57+
pk.Property(x => x.Key2, x =>
58+
{
59+
x.Column("key2");
60+
});
61+
});
62+
63+
Property(x => x.Name);
64+
65+
Component<Address>(x => x.Address, map =>
66+
{
67+
map.Property(y => y.City, mc => mc.Column("city1"));
68+
});
69+
}
70+
}
71+
72+
class Child2Map : ClassMapping<Child2>
73+
{
74+
public Child2Map()
75+
{
76+
Table("Child2");
77+
78+
ComponentAsId<ParentId>(x => x.Id, pk =>
79+
{
80+
pk.Property(x => x.Key1, x => x.Column("key1"));
81+
pk.Property(x => x.Key2, x =>
82+
{
83+
x.Column("key2__");
84+
});
85+
});
86+
87+
Property(x => x.Name);
88+
89+
Component<Address>(x => x.Address, map =>
90+
{
91+
map.Property(y => y.City, mc => mc.Column("city2"));
92+
});
93+
}
94+
}
95+
96+
public class Address
97+
{
98+
public virtual string City { get; set; }
99+
}
100+
101+
[TestFixture]
102+
public class ComponentAsIdTest
103+
{
104+
[Test]
105+
public void CanHaveSameComponentAsIdMultipleTimesWithDifferentColumnNamesForSameProperty()
106+
{
107+
//NH-3650
108+
var model = new ModelMapper();
109+
model.AddMapping<Child1Map>();
110+
model.AddMapping<Child2Map>();
111+
112+
var mappings = model.CompileMappingForEach(new[] { typeof(Child1), typeof(Child2) });
113+
114+
var child1Mapping = mappings.ElementAt(0);
115+
Assert.AreEqual("city1", child1Mapping.RootClasses[0].Properties.OfType<HbmComponent>().First().Properties.OfType<HbmProperty>().Single().column);
116+
//next one fails
117+
Assert.AreEqual("key2", child1Mapping.RootClasses[0].CompositeId.Items.OfType<HbmKeyProperty>().Last().column1);
118+
119+
var child2Mapping = mappings.ElementAt(1);
120+
Assert.AreEqual("city2", child2Mapping.RootClasses[0].Properties.OfType<HbmComponent>().First().Properties.OfType<HbmProperty>().Single().column);
121+
Assert.AreEqual("key2__", child2Mapping.RootClasses[0].CompositeId.Items.OfType<HbmKeyProperty>().Last().column1);
122+
}
123+
}
124+
}

src/NHibernate.Test/NHSpecificTest/NH1981/Fixture.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ namespace NHibernate.Test.NHSpecificTest.NH1981
55
[TestFixture]
66
public class Fixture : BugTestCase
77
{
8+
protected override bool AppliesTo(Dialect.Dialect dialect)
9+
{
10+
// Firebird doesn't support this feature
11+
return !(dialect is Dialect.FirebirdDialect);
12+
}
13+
814
protected override void OnSetUp()
915
{
1016
using (var s = OpenSession())
@@ -24,7 +30,7 @@ protected override void OnTearDown()
2430
using (var tx = s.BeginTransaction())
2531
{
2632
s.Delete("from Article");
27-
33+
2834
tx.Commit();
2935
}
3036
}

src/NHibernate.Test/NHSpecificTest/NH1989/Fixture.cs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ namespace NHibernate.Test.NHSpecificTest.NH1989
1515
[TestFixture]
1616
public class Fixture : BugTestCase
1717
{
18+
protected override bool AppliesTo(ISessionFactoryImplementor factory)
19+
{
20+
return factory.ConnectionProvider.Driver.SupportsMultipleQueries;
21+
}
22+
1823
protected override void OnSetUp()
1924
{
2025
cfg.Properties[Environment.CacheProvider] = typeof(HashtableCacheProvider).AssemblyQualifiedName;
@@ -47,7 +52,7 @@ public void SecondLevelCacheWithSingleCacheableFuture()
4752
using (ISession s = OpenSession())
4853
using (ITransaction tx = s.BeginTransaction())
4954
{
50-
User user = new User() { Name="test" };
55+
User user = new User() { Name = "test" };
5156
s.Save(user);
5257
tx.Commit();
5358
}
@@ -87,7 +92,7 @@ public void SecondLevelCacheWithDifferentRegionsFuture()
8792
using (ISession s = OpenSession())
8893
using (ITransaction tx = s.BeginTransaction())
8994
{
90-
User user = new User() { Name="test" };
95+
User user = new User() { Name = "test" };
9196
s.Save(user);
9297
tx.Commit();
9398
}
@@ -129,7 +134,7 @@ public void SecondLevelCacheWithMixedCacheableAndNonCacheableFuture()
129134
using (ISession s = OpenSession())
130135
using (ITransaction tx = s.BeginTransaction())
131136
{
132-
User user = new User() { Name="test" };
137+
User user = new User() { Name = "test" };
133138
s.Save(user);
134139
tx.Commit();
135140
}
@@ -181,7 +186,7 @@ public void SecondLevelCacheWithMixedCacheRegionsFuture()
181186
using (ISession s = OpenSession())
182187
using (ITransaction tx = s.BeginTransaction())
183188
{
184-
User user = new User() { Name="test" };
189+
User user = new User() { Name = "test" };
185190
s.Save(user);
186191
tx.Commit();
187192
}
@@ -239,7 +244,7 @@ public void SecondLevelCacheWithSingleCacheableQueryFuture()
239244
using (ISession s = OpenSession())
240245
using (ITransaction tx = s.BeginTransaction())
241246
{
242-
User user = new User() { Name="test" };
247+
User user = new User() { Name = "test" };
243248
s.Save(user);
244249
tx.Commit();
245250
}

0 commit comments

Comments
 (0)