-
Notifications
You must be signed in to change notification settings - Fork 933
Fix implied commits for Oracle and MySQL #3485
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
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
931d35f
Add test case for #3474
fredericDelaporte 0e8a9a1
Fix #3474
fredericDelaporte 71a1648
Generate async
fredericDelaporte f06b8b3
Fix MySQL undue implied commit
fredericDelaporte 8e46825
Merge branch 'master' into GH3474
fredericDelaporte fa99353
Merge branch 'master' into GH3474
hazzik File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
81 changes: 81 additions & 0 deletions
81
src/NHibernate.Test/Async/NHSpecificTest/GH3474/Fixture.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
//------------------------------------------------------------------------------ | ||
// <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 System.Linq; | ||
using NUnit.Framework; | ||
using NHibernate.Linq; | ||
|
||
namespace NHibernate.Test.NHSpecificTest.GH3474 | ||
{ | ||
using System.Threading.Tasks; | ||
[TestFixture] | ||
public class FixtureAsync : BugTestCase | ||
{ | ||
protected override void OnSetUp() | ||
{ | ||
using var session = OpenSession(); | ||
using var transaction = session.BeginTransaction(); | ||
|
||
var e1 = new CreditCardPayment { CreditCardType = "Visa", Amount = 50 }; | ||
session.Save(e1); | ||
|
||
var e2 = new ChequePayment { Bank = "CA", Amount = 32 }; | ||
session.Save(e2); | ||
|
||
var e3 = new CashPayment { Amount = 18.5m }; | ||
session.Save(e3); | ||
|
||
transaction.Commit(); | ||
} | ||
|
||
protected override void OnTearDown() | ||
{ | ||
using var session = OpenSession(); | ||
using var transaction = session.BeginTransaction(); | ||
|
||
// The HQL delete does all the job inside the database without loading the entities, but it does | ||
// not handle delete order for avoiding violating constraints if any. Use | ||
// session.Delete("from System.Object"); | ||
// instead if in need of having NHibernate ordering the deletes, but this will cause | ||
// loading the entities in the session. | ||
session.CreateQuery("delete from System.Object").ExecuteUpdate(); | ||
|
||
transaction.Commit(); | ||
} | ||
|
||
[Test] | ||
public async Task PolymorphicUpdateShouldNotCommitAsync() | ||
{ | ||
using (var session = OpenSession()) | ||
using (var transaction = session.BeginTransaction()) | ||
{ | ||
var payment = await (session.Query<CreditCardPayment>().FirstAsync()); | ||
payment.Amount = 100; | ||
await (session.FlushAsync()); | ||
|
||
await (session.CreateQuery("update ChequePayment set Amount = 64").ExecuteUpdateAsync()); | ||
|
||
await (transaction.RollbackAsync()); | ||
} | ||
|
||
using (var session = OpenSession()) | ||
using (var transaction = session.BeginTransaction()) | ||
{ | ||
IPayment payment = await (session.Query<CreditCardPayment>().FirstAsync()); | ||
Assert.That(payment.Amount, Is.EqualTo(50m)); | ||
|
||
payment = await (session.Query<ChequePayment>().FirstAsync()); | ||
Assert.That(payment.Amount, Is.EqualTo(32m)); | ||
|
||
await (transaction.CommitAsync()); | ||
} | ||
} | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
using System; | ||
|
||
namespace NHibernate.Test.NHSpecificTest.GH3474 | ||
{ | ||
public interface IPayment | ||
{ | ||
public Guid Id { get; set; } | ||
public decimal Amount { get; set; } | ||
} | ||
|
||
public class CreditCardPayment : IPayment | ||
{ | ||
public virtual Guid Id { get; set; } | ||
public virtual decimal Amount { get; set; } | ||
public virtual string CreditCardType { get; set; } | ||
} | ||
|
||
public class CashPayment : IPayment | ||
{ | ||
public virtual Guid Id { get; set; } | ||
public virtual decimal Amount { get; set; } | ||
} | ||
|
||
public class ChequePayment : IPayment | ||
{ | ||
public virtual Guid Id { get; set; } | ||
public virtual decimal Amount { get; set; } | ||
public virtual string Bank { get; set; } | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
using System.Linq; | ||
using NUnit.Framework; | ||
|
||
namespace NHibernate.Test.NHSpecificTest.GH3474 | ||
{ | ||
[TestFixture] | ||
public class Fixture : BugTestCase | ||
{ | ||
protected override void OnSetUp() | ||
{ | ||
using var session = OpenSession(); | ||
using var transaction = session.BeginTransaction(); | ||
|
||
var e1 = new CreditCardPayment { CreditCardType = "Visa", Amount = 50 }; | ||
session.Save(e1); | ||
|
||
var e2 = new ChequePayment { Bank = "CA", Amount = 32 }; | ||
session.Save(e2); | ||
|
||
var e3 = new CashPayment { Amount = 18.5m }; | ||
session.Save(e3); | ||
|
||
transaction.Commit(); | ||
} | ||
|
||
protected override void OnTearDown() | ||
{ | ||
using var session = OpenSession(); | ||
using var transaction = session.BeginTransaction(); | ||
|
||
// The HQL delete does all the job inside the database without loading the entities, but it does | ||
// not handle delete order for avoiding violating constraints if any. Use | ||
// session.Delete("from System.Object"); | ||
// instead if in need of having NHibernate ordering the deletes, but this will cause | ||
// loading the entities in the session. | ||
session.CreateQuery("delete from System.Object").ExecuteUpdate(); | ||
|
||
transaction.Commit(); | ||
} | ||
|
||
[Test] | ||
public void PolymorphicUpdateShouldNotCommit() | ||
{ | ||
using (var session = OpenSession()) | ||
using (var transaction = session.BeginTransaction()) | ||
{ | ||
var payment = session.Query<CreditCardPayment>().First(); | ||
payment.Amount = 100; | ||
session.Flush(); | ||
|
||
session.CreateQuery("update ChequePayment set Amount = 64").ExecuteUpdate(); | ||
|
||
transaction.Rollback(); | ||
} | ||
|
||
using (var session = OpenSession()) | ||
using (var transaction = session.BeginTransaction()) | ||
{ | ||
IPayment payment = session.Query<CreditCardPayment>().First(); | ||
Assert.That(payment.Amount, Is.EqualTo(50m)); | ||
|
||
payment = session.Query<ChequePayment>().First(); | ||
Assert.That(payment.Amount, Is.EqualTo(32m)); | ||
|
||
transaction.Commit(); | ||
} | ||
} | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
src/NHibernate.Test/NHSpecificTest/GH3474/Mappings.hbm.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="NHibernate.Test" | ||
namespace="NHibernate.Test.NHSpecificTest.GH3474"> | ||
|
||
<class name="IPayment" table="Payment"> | ||
<id name="Id" generator="guid.comb" /> | ||
<property name="Amount" /> | ||
<joined-subclass name="CreditCardPayment"> | ||
<key column="Id" /> | ||
<property name="CreditCardType" /> | ||
</joined-subclass> | ||
<joined-subclass name="CashPayment"> | ||
<key column="Id"/> | ||
</joined-subclass> | ||
<joined-subclass name="ChequePayment"> | ||
<key column="Id"/> | ||
<property name="Bank" /> | ||
</joined-subclass> | ||
</class> | ||
|
||
</hibernate-mapping> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.