-
Notifications
You must be signed in to change notification settings - Fork 933
Fix #2608 - persisting a one-to-one with delayed insert fails #2609
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
6b024b6
fc00120
7d17eeb
8b50340
8d02bd0
0c78505
3f1b305
a9861ba
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
//------------------------------------------------------------------------------ | ||
// <auto-generated> | ||
// This code was generated by AsyncGenerator. | ||
// | ||
// Changes to this file may cause incorrect behavior and will be lost if | ||
// the code is regenerated. | ||
// </auto-generated> | ||
//------------------------------------------------------------------------------ | ||
|
||
|
||
using NUnit.Framework; | ||
|
||
namespace NHibernate.Test.NHSpecificTest.GH2608 | ||
{ | ||
using System.Threading.Tasks; | ||
[TestFixture] | ||
public class FixtureAsync : BugTestCase | ||
{ | ||
protected override void OnTearDown() | ||
{ | ||
using (var session = OpenSession()) | ||
using (var transaction = session.BeginTransaction()) | ||
{ | ||
session.CreateQuery("delete from PersonalDetails").ExecuteUpdate(); | ||
session.CreateQuery("delete from System.Object").ExecuteUpdate(); | ||
|
||
transaction.Commit(); | ||
} | ||
} | ||
|
||
[Test] | ||
public async Task MergeBidiPrimaryKeyOneToOneAsync() | ||
{ | ||
using (var s = OpenSession()) | ||
using (var tx = s.BeginTransaction()) | ||
{ | ||
var p = new Person { Name = "steve" }; | ||
p.Details = new PersonalDetails { SomePersonalDetail = "I have big feet", Person = p }; | ||
await (s.MergeAsync(p)); | ||
await (tx.CommitAsync()); | ||
} | ||
} | ||
|
||
[Test] | ||
public async Task PersistBidiPrimaryKeyOneToOneAsync() | ||
{ | ||
using (var s = OpenSession()) | ||
using (var tx = s.BeginTransaction()) | ||
{ | ||
var p = new Person { Name = "steve" }; | ||
p.Details = new PersonalDetails { SomePersonalDetail = "I have big feet", Person = p }; | ||
await (s.PersistAsync(p)); | ||
await (tx.CommitAsync()); | ||
} | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
using NUnit.Framework; | ||
|
||
namespace NHibernate.Test.NHSpecificTest.GH2608 | ||
{ | ||
[TestFixture] | ||
public class Fixture : BugTestCase | ||
{ | ||
protected override void OnTearDown() | ||
{ | ||
using (var session = OpenSession()) | ||
using (var transaction = session.BeginTransaction()) | ||
{ | ||
session.CreateQuery("delete from PersonalDetails").ExecuteUpdate(); | ||
session.CreateQuery("delete from System.Object").ExecuteUpdate(); | ||
|
||
transaction.Commit(); | ||
} | ||
} | ||
|
||
[Test] | ||
public void MergeBidiPrimaryKeyOneToOne() | ||
{ | ||
using (var s = OpenSession()) | ||
using (var tx = s.BeginTransaction()) | ||
{ | ||
var p = new Person { Name = "steve" }; | ||
p.Details = new PersonalDetails { SomePersonalDetail = "I have big feet", Person = p }; | ||
s.Merge(p); | ||
tx.Commit(); | ||
} | ||
} | ||
|
||
[Test] | ||
public void PersistBidiPrimaryKeyOneToOne() | ||
{ | ||
using (var s = OpenSession()) | ||
using (var tx = s.BeginTransaction()) | ||
{ | ||
var p = new Person { Name = "steve" }; | ||
p.Details = new PersonalDetails { SomePersonalDetail = "I have big feet", Person = p }; | ||
s.Persist(p); | ||
tx.Commit(); | ||
} | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" | ||
assembly="NHibernate.Test" | ||
namespace="NHibernate.Test.NHSpecificTest.GH2608"> | ||
|
||
<class name="Person"> | ||
<id name="Id"> | ||
<generator class="native"/> | ||
</id> | ||
<property name="Name"/> | ||
<one-to-one name="Details" class="PersonalDetails" cascade="all"/> | ||
</class> | ||
|
||
<class name="PersonalDetails"> | ||
<id name="Id"> | ||
<generator class="foreign"> | ||
<param name="property">Person</param> | ||
</generator> | ||
</id> | ||
<property name="SomePersonalDetail"/> | ||
<one-to-one name="Person" class="Person" constrained="true"/> | ||
</class> | ||
|
||
</hibernate-mapping> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
namespace NHibernate.Test.NHSpecificTest.GH2608 | ||
{ | ||
public class Person | ||
{ | ||
public virtual long Id { get; set; } | ||
public virtual string Name { get; set; } | ||
public virtual PersonalDetails Details { get; set; } | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
namespace NHibernate.Test.NHSpecificTest.GH2608 | ||
{ | ||
public class PersonalDetails | ||
{ | ||
public virtual long Id { get; set; } | ||
public virtual string SomePersonalDetail { get; set; } | ||
|
||
public virtual Person Person { get; set; } | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,10 +32,12 @@ | |
|
||
<class name="PersonalDetails" table="OPS_PERS_DETAIL"> | ||
<id name="Id" column="ID" type="long"> | ||
<generator class="increment"/> | ||
<generator class="foreign"> | ||
<param name="property">Person</param> | ||
</generator> | ||
Comment on lines
-35
to
+37
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We already had a test really near what is required for reproducing #2608, unfortunately ignored and anyway, not using an id strategy on its parent which would be adequate for triggering the bug. As switching the parent id strategy would impact other tests, I have just fix that other test. |
||
</id> | ||
<property name="SomePersonalDetail" column="SOME_DETAIL" type="string"/> | ||
<one-to-one name="Person" class="Person" constrained="true" /> | ||
</class> | ||
|
||
</hibernate-mapping> | ||
</hibernate-mapping> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like the same exception should be thrown on
Persist
too. Am I right?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, persist does not fail, it least with my tests on a modified MergeFixture.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Strange... I thought it's directly related to #1754 in which case Persist should fail the same (at least for this test case). I added test for Persist - let's see...
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And Persist fails the same...
But in current state it also doesn't fail on Merge.... The only failed tests are newly added GH2608
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
MergeFixture
one fails if we change its id generator fromincrement
toidentity
. But as this would mean changing from a app-side generated id to a db-side one, I have not done that change, it would change too much the test.I have re-checked these GH2608 tests on 5.2.x just in case, both succeed on 5.2.x.