-
Notifications
You must be signed in to change notification settings - Fork 925
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use table group joins for many-to-many in Criteria and Entity loaders (…
…#2687) Possible breaking change: Default not-found behavior now works correctly for many-to-many in Criteria so now it throws ObjectNotFoundException exception on many-to-many Criteria fetch for not found records.
- Loading branch information
Showing
20 changed files
with
581 additions
and
279 deletions.
There are no files selected for viewing
This file contains 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 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
85 changes: 85 additions & 0 deletions
85
src/NHibernate.Test/Async/NHSpecificTest/NH750/ManyToManyThrowsForNotFoundFixture.cs
This file contains 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,85 @@ | ||
//------------------------------------------------------------------------------ | ||
// <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 NHibernate.Criterion; | ||
using NHibernate.Linq; | ||
using NHibernate.Transform; | ||
using NUnit.Framework; | ||
|
||
namespace NHibernate.Test.NHSpecificTest.NH750 | ||
{ | ||
using System.Threading.Tasks; | ||
[TestFixture] | ||
public class ManyToManyThrowsForNotFoundFixtureAsync : BugTestCase | ||
{ | ||
private int _id; | ||
|
||
protected override void OnSetUp() | ||
{ | ||
using (var s = Sfi.OpenSession()) | ||
using (var t = s.BeginTransaction()) | ||
{ | ||
Device dv = new Device("Device"); | ||
Drive dr = new Drive("Drive"); | ||
s.Save(dr); | ||
dv.DrivesNotIgnored.Add(dr); | ||
|
||
_id = (int) s.Save(dv); | ||
s.Flush(); | ||
|
||
s.Clear(); | ||
s.Delete(dr); | ||
t.Commit(); | ||
} | ||
} | ||
|
||
protected override void OnTearDown() | ||
{ | ||
using (var s = OpenSession()) | ||
using (var t = s.BeginTransaction()) | ||
{ | ||
s.Delete("from Device"); | ||
s.Delete("from Drive"); | ||
t.Commit(); | ||
} | ||
} | ||
|
||
[Test] | ||
public async Task LazyLoadAsync() | ||
{ | ||
using var s = OpenSession(); | ||
var device = await (s.GetAsync<Device>(_id)); | ||
Assert.ThrowsAsync<ObjectNotFoundException>(() => NHibernateUtil.InitializeAsync(device.DrivesNotIgnored)); | ||
} | ||
|
||
[Test] | ||
public void QueryOverFetchAsync() | ||
{ | ||
using var s = OpenSession(); | ||
var queryOver = s.QueryOver<Device>() | ||
.Fetch(SelectMode.Fetch, x => x.DrivesNotIgnored) | ||
.Where(Restrictions.IdEq(_id)) | ||
.TransformUsing(Transformers.DistinctRootEntity); | ||
Assert.ThrowsAsync<ObjectNotFoundException>(async () => await (NHibernateUtil.InitializeAsync(await (queryOver.SingleOrDefaultAsync())))); | ||
} | ||
|
||
[Test] | ||
public void LinqFetchAsync() | ||
{ | ||
using var s = OpenSession(); | ||
var query = s.Query<Device>() | ||
|
||
.Fetch(x => x.DrivesNotIgnored) | ||
.Where(x => x.Id == _id); | ||
Assert.ThrowsAsync<ObjectNotFoundException>(async () => await (NHibernateUtil.InitializeAsync(await (query.SingleOrDefaultAsync())))); | ||
} | ||
} | ||
} |
This file contains 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
Oops, something went wrong.