Skip to content

Commit e662e7c

Browse files
committed
NH-3997 - SqlServer CE: Make native generator to be TableHiLoGenerator
* Adjust tests wrongly assuming the behaviour of id generator
1 parent 0d071ff commit e662e7c

File tree

4 files changed

+48
-41
lines changed

4 files changed

+48
-41
lines changed

src/NHibernate.Test/Cascade/Circle/CascadeMergeToChildBeforeParentTest.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,19 +41,20 @@ protected override IList Mappings
4141
[Test]
4242
public void Merge()
4343
{
44+
object routeId;
4445
using (ISession session = base.OpenSession())
4546
using (ITransaction transaction = session.BeginTransaction())
4647
{
4748
Route route = new Route();
4849
route.Name = "routeA";
49-
session.Save(route);
50+
routeId = session.Save(route);
5051
transaction.Commit();
5152
}
5253

5354
using (ISession session = base.OpenSession())
5455
using (ITransaction transaction = session.BeginTransaction())
5556
{
56-
Route route = session.Get<Route>(1L);
57+
Route route = session.Get<Route>(routeId);
5758
route.TransientField = "sfnaouisrbn";
5859

5960
Tour tour = new Tour();

src/NHibernate.Test/CfgTest/ConfigurationSerializationTests.cs

Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -37,28 +37,28 @@ public void Basic_CRUD_should_work()
3737

3838
var export = new SchemaExport(cfg);
3939
export.Execute(true, true, false);
40-
ISessionFactory sf = cfg.BuildSessionFactory();
41-
using (ISession session = sf.OpenSession())
40+
var sf = cfg.BuildSessionFactory();
41+
object parentId;
42+
object childId;
43+
using (var session = sf.OpenSession())
44+
using (var tran = session.BeginTransaction())
4245
{
43-
using (ITransaction tran = session.BeginTransaction())
44-
{
45-
var parent = new Parent();
46-
var child = new Child();
47-
parent.Child = child;
48-
parent.X = 9;
49-
parent.Count = 5;
50-
child.Parent = parent;
51-
child.Count = 3;
52-
child.X = 4;
53-
session.Save(parent);
54-
session.Save(child);
55-
tran.Commit();
56-
}
46+
var parent = new Parent();
47+
var child = new Child();
48+
parent.Child = child;
49+
parent.X = 9;
50+
parent.Count = 5;
51+
child.Parent = parent;
52+
child.Count = 3;
53+
child.X = 4;
54+
parentId = session.Save(parent);
55+
childId = session.Save(child);
56+
tran.Commit();
5757
}
5858

5959
using (ISession session = sf.OpenSession())
6060
{
61-
var parent = session.Get<Parent>(1L);
61+
var parent = session.Get<Parent>(parentId);
6262
Assert.That(parent.Count, Is.EqualTo(5));
6363
Assert.That(parent.X, Is.EqualTo(9));
6464
Assert.That(parent.Child, Is.Not.Null);
@@ -68,19 +68,18 @@ public void Basic_CRUD_should_work()
6868
}
6969

7070
using (ISession session = sf.OpenSession())
71+
using (ITransaction tran = session.BeginTransaction())
7172
{
72-
using (ITransaction tran = session.BeginTransaction())
73-
{
74-
var p = session.Get<Parent>(1L);
75-
var c = session.Get<Child>(1L);
76-
session.Delete(c);
77-
session.Delete(p);
78-
tran.Commit();
79-
}
73+
var p = session.Get<Parent>(parentId);
74+
var c = session.Get<Child>(childId);
75+
session.Delete(c);
76+
session.Delete(p);
77+
tran.Commit();
8078
}
79+
8180
using (ISession session = sf.OpenSession())
8281
{
83-
var p = session.Get<Parent>(1L);
82+
var p = session.Get<Parent>(parentId);
8483
Assert.That(p, Is.Null);
8584
}
8685
export.Drop(true, true);

src/NHibernate.Test/NHSpecificTest/NH1391/Fixture2.cs

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,29 @@ namespace NHibernate.Test.NHSpecificTest.NH1391
55
[TestFixture]
66
public class Fixture2:BugTestCase
77
{
8+
object _personId;
9+
810
protected override void OnSetUp()
911
{
1012
using (var session = OpenSession())
1113
using (var tran = session.BeginTransaction())
1214
{
13-
PersonWithAllTypes personWithAllTypes = new PersonWithAllTypes();
14-
Animal animal = new Animal { Name = "Pasha", Owner = personWithAllTypes };
15-
Dog dog = new Dog { Country = "Turkey", Name = "Kral", Owner = personWithAllTypes };
16-
SivasKangal sivasKangal = new SivasKangal
17-
{
18-
Name = "Karabas",
19-
Country = "Turkey",
20-
HouseAddress = "Address",
21-
Owner = personWithAllTypes
22-
};
23-
Cat cat = new Cat { Name = "Tekir", EyeColor = "Red", Owner = personWithAllTypes };
15+
var personWithAllTypes = new PersonWithAllTypes();
16+
var animal = new Animal { Name = "Pasha", Owner = personWithAllTypes };
17+
var dog = new Dog { Country = "Turkey", Name = "Kral", Owner = personWithAllTypes };
18+
var sivasKangal = new SivasKangal
19+
{
20+
Name = "Karabas",
21+
Country = "Turkey",
22+
HouseAddress = "Address",
23+
Owner = personWithAllTypes
24+
};
25+
var cat = new Cat { Name = "Tekir", EyeColor = "Red", Owner = personWithAllTypes };
2426
personWithAllTypes.AnimalsGeneric.Add(animal);
2527
personWithAllTypes.AnimalsGeneric.Add(cat);
2628
personWithAllTypes.AnimalsGeneric.Add(dog);
2729
personWithAllTypes.AnimalsGeneric.Add(sivasKangal);
28-
session.Save(personWithAllTypes);
30+
_personId = session.Save(personWithAllTypes);
2931
tran.Commit();
3032
}
3133
}
@@ -47,7 +49,7 @@ public void Can_discriminate_subclass_on_list_with_lazy_loading_when_used_and_pe
4749
using (var session = OpenSession())
4850
using (var tran = session.BeginTransaction())
4951
{
50-
var personWithAnimals = session.Get<PersonWithAllTypes>(1);
52+
var personWithAnimals = session.Get<PersonWithAllTypes>(_personId);
5153
Assert.That(personWithAnimals.AnimalsGeneric, Has.Count.EqualTo(4));
5254
Assert.That(personWithAnimals.CatsGeneric,Has.Count.EqualTo(1));
5355
Assert.That(personWithAnimals.DogsGeneric,Has.Count.EqualTo(2));

src/NHibernate/Dialect/MsSqlCeDialect.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using System.Text;
55
using NHibernate.Dialect.Function;
66
using NHibernate.Dialect.Schema;
7+
using NHibernate.Id;
78
using NHibernate.SqlCommand;
89
using NHibernate.Util;
910
using Environment = NHibernate.Cfg.Environment;
@@ -124,6 +125,10 @@ public override bool SupportsLimitOffset
124125
get { return false; }
125126
}
126127

128+
public override System.Type NativeIdentifierGeneratorClass => typeof(TableHiLoGenerator);
129+
130+
public override bool SupportsCircularCascadeDeleteConstraints => false;
131+
127132
public override IDataBaseSchema GetDataBaseSchema(DbConnection connection)
128133
{
129134
return new MsSqlCeDataBaseSchema(connection);

0 commit comments

Comments
 (0)