Skip to content

Fix Criteria caching filtered collections #460

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
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
a251d32
Tests using Criteria and QueryOver for NH-3848
itmagination Feb 23, 2016
d0fe800
Fix using Criteria and QuerOver for NH-3848
itmagination Feb 23, 2016
d35233e
Child collection fetched using left join with restrictions shouldn’t …
Nov 14, 2018
b66721f
Fix tests NH 3848 for Firebird
Nov 14, 2018
34974e7
Fix async tests Nh 3848
Nov 14, 2018
b0fea9a
Add autogenerated async code
Nov 15, 2018
2f1b4e4
Mark methods without uncacheableCollections parameter as obsolete
Nov 15, 2018
772f4b7
Reformat
Nov 15, 2018
39350bb
Fix mapping in tests for Oracle
Nov 16, 2018
e4c72c8
Fix Oracle failures
fredericDelaporte Nov 16, 2018
f05c212
Reformat tests for better readability on GitHub
fredericDelaporte Nov 16, 2018
be6c08e
Do some more reformatting
fredericDelaporte Nov 16, 2018
c57a703
Do some additional cleanup
fredericDelaporte Nov 16, 2018
32c1f8b
Skipping collections cache inside JoinWalker
Nov 20, 2018
bbb4d9e
CriteriaQueryTranslator is responsible now for creating UncacheableC…
Nov 20, 2018
c25658e
Refactoring and clean up
bahusoid Nov 20, 2018
73b0831
Hide implementation detail of CacheableCollectionPersister logic
hazzik Nov 20, 2018
5176e35
fixup! Hide implementation detail of CacheableCollectionPersister logic
hazzik Nov 20, 2018
937f1c2
fixup! Hide implementation detail of CacheableCollectionPersister logic
bahusoid Nov 21, 2018
6cbbf46
fixup! Hide implementation detail of CacheableCollectionPersister logic
bahusoid Nov 21, 2018
d19e632
Merge branch 'master' into NH-3848_Criteria_And_QueryOver
fredericDelaporte Nov 21, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
221 changes: 221 additions & 0 deletions src/NHibernate.Test/Async/NHSpecificTest/NH3848/CriteriaTestFixture.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,221 @@
//------------------------------------------------------------------------------
// <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.Collections.Generic;
using NHibernate.Criterion;
using NHibernate.SqlCommand;
using NHibernate.Transform;

namespace NHibernate.Test.NHSpecificTest.NH3848
{
using System.Threading.Tasks;
using System.Threading;
public class CriteriaTestFixtureAsync : FixtureAsync
{
protected override Task<IList<Customer>> GetCustomersWithOrdersEagerLoadedAsync(ISession session, CancellationToken cancellationToken = default(CancellationToken))
{
try
{
return
session
.CreateCriteria<Customer>()
.Fetch("Orders")
.SetResultTransformer(new DistinctRootEntityResultTransformer())
.ListAsync<Customer>(cancellationToken);
}
catch (System.Exception ex)
{
return Task.FromException<IList<Customer>>(ex);
}
}

protected override Task<IList<Customer>> GetCustomersByOrderNumberUsingOnClauseAsync(ISession session, int orderNumber, CancellationToken cancellationToken = default(CancellationToken))
{
try
{
return
session
.CreateCriteria<Customer>()
.CreateAlias("Orders", "order", JoinType.LeftOuterJoin, Restrictions.Eq("Number", orderNumber))
.ListAsync<Customer>(cancellationToken);
}
catch (System.Exception ex)
{
return Task.FromException<IList<Customer>>(ex);
}
}

protected override Task<IList<Customer>> GetCustomersByOrderNumberUsingFetchAsync(ISession session, int orderNumber, CancellationToken cancellationToken = default(CancellationToken))
{
try
{
return
session
.CreateCriteria<Customer>()
.CreateAlias("Orders", "order", JoinType.InnerJoin, Restrictions.Eq("Number", orderNumber))
.Fetch(SelectMode.Fetch, "Orders")
.ListAsync<Customer>(cancellationToken);
}
catch (System.Exception ex)
{
return Task.FromException<IList<Customer>>(ex);
}
}

protected override Task<IList<Customer>> GetCustomersByOrderNumberUsingFetchAndWhereClauseAsync(ISession session, int orderNumber, CancellationToken cancellationToken = default(CancellationToken))
{
try
{
return
session
.CreateCriteria<Customer>()
.Fetch(SelectMode.Fetch, "Orders")
.CreateCriteria("Orders", JoinType.InnerJoin)
.Add(Restrictions.Eq("Number", orderNumber))
.ListAsync<Customer>(cancellationToken);
}
catch (System.Exception ex)
{
return Task.FromException<IList<Customer>>(ex);
}
}

protected override Task<IList<Customer>> GetCustomersAndCompaniesByOrderNumberUsingFetchAndWhereClauseAsync(ISession session, int orderNumber, string name, CancellationToken cancellationToken = default(CancellationToken))
{
try
{
return
session
.CreateCriteria<Customer>()
.CreateAlias("Orders", "order", JoinType.InnerJoin, Restrictions.Eq("Number", orderNumber))
.Fetch(SelectMode.Fetch, "Orders")
.CreateAlias("Companies", "company", JoinType.LeftOuterJoin, Restrictions.Eq("Name", name))
.ListAsync<Customer>(cancellationToken);
}
catch (System.Exception ex)
{
return Task.FromException<IList<Customer>>(ex);
}
}

protected override Task<IList<Customer>> GetCustomersAndCompaniesByOrderNumberUsingFetchWithoutRestrictionsAsync(ISession session, CancellationToken cancellationToken = default(CancellationToken))
{
try
{
return
session
.CreateCriteria<Customer>()
.Fetch(SelectMode.Fetch, "Orders")
.CreateAlias("Orders", "order", JoinType.InnerJoin)
.CreateAlias("Companies", "company", JoinType.LeftOuterJoin)
.ListAsync<Customer>(cancellationToken);
}
catch (System.Exception ex)
{
return Task.FromException<IList<Customer>>(ex);
}
}

protected override Task<IList<Customer>> GetCustomersWithCompaniesByOrderNumberUsingOnClauseAsync(
ISession session,
int orderNumber, CancellationToken cancellationToken = default(CancellationToken))
{
try
{
return
session
.CreateCriteria<Customer>()
.CreateAlias("Orders", "order", JoinType.LeftOuterJoin, Restrictions.Eq("Number", orderNumber))
.CreateAlias("Companies", "company", JoinType.LeftOuterJoin)
.ListAsync<Customer>(cancellationToken);
}
catch (System.Exception ex)
{
return Task.FromException<IList<Customer>>(ex);
}
}

protected override Task<IList<Customer>> GetCustomersByOrderNumberUsingWhereClauseAsync(ISession session, int orderNumber, CancellationToken cancellationToken = default(CancellationToken))
{
try
{
return
session
.CreateCriteria<Customer>()
.CreateCriteria("Orders", "Order", JoinType.LeftOuterJoin)
.Add(Restrictions.Eq("Number", orderNumber))
.SetResultTransformer(new DistinctRootEntityResultTransformer())
.ListAsync<Customer>(cancellationToken);
}
catch (System.Exception ex)
{
return Task.FromException<IList<Customer>>(ex);
}
}

protected override Task<IList<Customer>> GetCustomersByNameUsingWhereClauseAsync(ISession session, string customerName, CancellationToken cancellationToken = default(CancellationToken))
{
try
{
return
session
.CreateCriteria<Customer>()
.CreateAlias("Orders", "order", JoinType.LeftOuterJoin)
.Add(Restrictions.Eq("Name", "First Customer"))
.SetResultTransformer(new DistinctRootEntityResultTransformer())
.ListAsync<Customer>(cancellationToken);
}
catch (System.Exception ex)
{
return Task.FromException<IList<Customer>>(ex);
}
}

protected override Task<IList<Customer>> GetCustomersByOrderNumberUsingSubqueriesAndByNameUsingWhereClauseAsync(
ISession session,
int orderNumber,
string customerName, CancellationToken cancellationToken = default(CancellationToken))
{
try
{
var detachedCriteria =
DetachedCriteria
.For<Customer>()
.CreateAlias("Orders", "order", JoinType.LeftOuterJoin, Restrictions.Eq("Number", orderNumber))
.SetProjection(Projections.Id());

return
session
.CreateCriteria<Customer>()
.CreateAlias("Orders", "order1", JoinType.LeftOuterJoin)
.Add(Subqueries.PropertyIn("Id", detachedCriteria))
.Add(Restrictions.Eq("Name", customerName))
.SetResultTransformer(new DistinctRootEntityResultTransformer())
.ListAsync<Customer>(cancellationToken);
}
catch (System.Exception ex)
{
return Task.FromException<IList<Customer>>(ex);
}
}

protected override Task<IList<Customer>> GetAllCustomersAsync(ISession session, CancellationToken cancellationToken = default(CancellationToken))
{
try
{
return session.CreateCriteria<Customer>().ListAsync<Customer>(cancellationToken);
}
catch (System.Exception ex)
{
return Task.FromException<IList<Customer>>(ex);
}
}
}
}
Loading