Skip to content

Commit 94f18d3

Browse files
Enable and fix merge on one to one test
1 parent 58e3cb2 commit 94f18d3

File tree

3 files changed

+46
-3
lines changed

3 files changed

+46
-3
lines changed

src/NHibernate.Test/Async/Operations/MergeFixture.cs

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ protected override void OnTearDown()
5050
await (s.DeleteAsync("from Competition", cancellationToken));
5151

5252
await (s.DeleteAsync("from Employer", cancellationToken));
53+
await (s.DeleteAsync("from Address", cancellationToken));
54+
await (s.DeleteAsync("from Person", cancellationToken));
5355

5456
await (tx.CommitAsync(cancellationToken));
5557
}
@@ -76,6 +78,8 @@ private void Cleanup()
7678
s.Delete("from Competition");
7779

7880
s.Delete("from Employer");
81+
s.Delete("from Address");
82+
s.Delete("from Person");
7983

8084
tx.Commit();
8185
}
@@ -156,6 +160,41 @@ public async Task MergeBidiForeignKeyOneToOneAsync()
156160
}
157161
}
158162

163+
[Test]
164+
public async Task MergeBidiPrimayKeyOneToOneAsync()
165+
{
166+
Person p;
167+
using (ISession s = OpenSession())
168+
using (ITransaction tx = s.BeginTransaction())
169+
{
170+
p = new Person {Name = "steve"};
171+
new PersonalDetails {SomePersonalDetail = "I have big feet", Person = p};
172+
await (s.PersistAsync(p));
173+
await (tx.CommitAsync());
174+
}
175+
176+
ClearCounts();
177+
178+
p.Details.SomePersonalDetail = p.Details.SomePersonalDetail + " and big hands too";
179+
using (ISession s = OpenSession())
180+
using (ITransaction tx = s.BeginTransaction())
181+
{
182+
p = (Person) await (s.MergeAsync(p));
183+
await (tx.CommitAsync());
184+
}
185+
186+
AssertInsertCount(0);
187+
AssertUpdateCount(1);
188+
AssertDeleteCount(0);
189+
190+
using (ISession s = OpenSession())
191+
using (ITransaction tx = s.BeginTransaction())
192+
{
193+
await (s.DeleteAsync(p));
194+
await (tx.CommitAsync());
195+
}
196+
}
197+
159198
[Test]
160199
public async Task MergeDeepTreeAsync()
161200
{

src/NHibernate.Test/Operations/MergeFixture.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ private void Cleanup()
3838
s.Delete("from Competition");
3939

4040
s.Delete("from Employer");
41+
s.Delete("from Address");
42+
s.Delete("from Person");
4143

4244
tx.Commit();
4345
}
@@ -118,7 +120,7 @@ public void MergeBidiForeignKeyOneToOne()
118120
}
119121
}
120122

121-
[Test, Ignore("Need some more investigation about id sync.")]
123+
[Test]
122124
public void MergeBidiPrimayKeyOneToOne()
123125
{
124126
Person p;

src/NHibernate.Test/Operations/OneToOne.hbm.xml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,12 @@
3232

3333
<class name="PersonalDetails" table="OPS_PERS_DETAIL">
3434
<id name="Id" column="ID" type="long">
35-
<generator class="increment"/>
35+
<generator class="foreign">
36+
<param name="property">Person</param>
37+
</generator>
3638
</id>
3739
<property name="SomePersonalDetail" column="SOME_DETAIL" type="string"/>
3840
<one-to-one name="Person" class="Person" constrained="true" />
3941
</class>
4042

41-
</hibernate-mapping>
43+
</hibernate-mapping>

0 commit comments

Comments
 (0)