Skip to content

NH-3848 - Tests and fix for HQL #463

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 19 commits into from
Feb 6, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
746 changes: 427 additions & 319 deletions src/NHibernate.Test/Async/NHSpecificTest/NH3848/Fixture.cs

Large diffs are not rendered by default.

184 changes: 184 additions & 0 deletions src/NHibernate.Test/Async/NHSpecificTest/NH3848/HqlTestFixture.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,184 @@
//------------------------------------------------------------------------------
// <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;
using System.Collections.Generic;
using NHibernate.Transform;
using NUnit.Framework;

namespace NHibernate.Test.NHSpecificTest.NH3848
{
using System.Threading.Tasks;
using System.Threading;
public class HqlTestFixtureAsync : FixtureAsync
{
[Ignore("We can't write such query using hql, because we can't use 'with' clause when we're fetching collection.")]
public override Task ChildCollectionsFromLeftOuterJoinWithOnClauseRestrictionOnCollectionShouldNotBeInSecondLevelCacheAsync()
{
throw new NotImplementedException();
}

[Ignore("We can't write such query using hql, because we can't use 'with' clause when we're fetching collection.")]
public override Task ChildCollectionsFromLeftOuterJoinOnlyWithRestrictionShouldNotBeIn2LvlCacheAsync()
{
throw new NotImplementedException();
}

[Ignore("We can't write such query using hql, because we can't use 'with' clause when we're fetching collection.")]
public override Task ChildCollectionsWithRestrictionShouldNotBeIn2LvlCacheAsync()
{
throw new NotImplementedException();
}

[Ignore("We can't write such query using hql, because we can't use 'with' clause when we're fetching collection.")]
public override Task ChildCollectionsWithSelectModeFetchOnCollectionShouldNotBeInSecondLevelCacheAsync()
{
throw new NotImplementedException();
}

protected override Task<IList<Customer>> GetCustomersWithOrdersEagerLoadedAsync(ISession session, CancellationToken cancellationToken = default(CancellationToken))
{
try
{
var query = session.CreateQuery("from Customer as c left join fetch c.Orders as o");
query.SetResultTransformer(new DistinctRootEntityResultTransformer());
return query.ListAsync<Customer>(cancellationToken);
}
catch (Exception ex)
{
return Task.FromException<IList<Customer>>(ex);
}
}

//We can't write such query using hql, because we can't use 'with' clause when we're fetching collection.
protected override Task<IList<Customer>> GetCustomersByOrderNumberUsingOnClauseAsync(ISession session, int orderNumber, CancellationToken cancellationToken = default(CancellationToken))
{
throw new NotImplementedException();
}

protected override Task<IList<Customer>> GetCustomersByOrderNumberUsingWhereClauseAsync(ISession session, int orderNumber, CancellationToken cancellationToken = default(CancellationToken))
{
try
{
var query = session.CreateQuery(
"from Customer as c " +
"left join fetch c.Orders as o " +
"where o.Number = :number");
query.SetParameter("number", orderNumber);
return query.ListAsync<Customer>(cancellationToken);
}
catch (Exception ex)
{
return Task.FromException<IList<Customer>>(ex);
}
}

protected override Task<IList<Customer>> GetCustomersByNameUsingWhereClauseAsync(ISession session, string customerName, CancellationToken cancellationToken = default(CancellationToken))
{
try
{
var query = session.CreateQuery(
"from Customer as c " +
"left join fetch c.Orders as o " +
"where c.Name = :name");
query.SetParameter("name", customerName);
query.SetResultTransformer(new DistinctRootEntityResultTransformer());
return query.ListAsync<Customer>(cancellationToken);
}
catch (Exception ex)
{
return Task.FromException<IList<Customer>>(ex);
}
}

//We can't write such query using hql, because we can't use 'with' clause when we're fetching collection.
protected override Task<IList<Customer>> GetCustomersByOrderNumberUsingFetchAsync(ISession session, int orderNumber, CancellationToken cancellationToken = default(CancellationToken))
{
throw new NotImplementedException();
}

protected override Task<IList<Customer>> GetCustomersByOrderNumberUsingFetchAndWhereClauseAsync(ISession session, int orderNumber, CancellationToken cancellationToken = default(CancellationToken))
{
try
{
var query = session.CreateQuery(
"from Customer as c " +
"inner join fetch c.Orders as o " +
"where o.Number = :number");
query.SetParameter("number", orderNumber);
return query.ListAsync<Customer>(cancellationToken);
}
catch (Exception ex)
{
return Task.FromException<IList<Customer>>(ex);
}
}

//We can't write such query using hql, because we can't use 'with' clause when we're fetching collection.
protected override Task<IList<Customer>> GetCustomersAndCompaniesByOrderNumberUsingFetchAndWhereClauseAsync(ISession session, int orderNumber, string name, CancellationToken cancellationToken = default(CancellationToken))
{
throw new NotImplementedException();
}

protected override Task<IList<Customer>> GetCustomersAndCompaniesByOrderNumberUsingFetchWithoutRestrictionsAsync(ISession session, CancellationToken cancellationToken = default(CancellationToken))
{
try
{
var query = session.CreateQuery(
"from Customer as c " +
"inner join fetch c.Orders as o " +
"left join fetch c.Companies as cmp");
return query.ListAsync<Customer>(cancellationToken);
}
catch (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 query = session.CreateQuery(
"from Customer as c " +
"left join fetch c.Orders as o " +
"where c.Name = :name and " +
"c.Id in (select c1.Id from Customer as c1 left join c1.Orders as o2 where o2.Number = :number)");
query.SetParameter("name", customerName);
query.SetParameter("number", orderNumber);
query.SetResultTransformer(new DistinctRootEntityResultTransformer());
return query.ListAsync<Customer>(cancellationToken);
}
catch (Exception ex)
{
return Task.FromException<IList<Customer>>(ex);
}
}

//We can't write such query using hql, because we can't use 'with' clause when we're fetching collection.
protected override Task<IList<Customer>> GetCustomersWithCompaniesByOrderNumberUsingOnClauseAsync(ISession session, int orderNumber, CancellationToken cancellationToken = default(CancellationToken))
{
throw new NotImplementedException();
}

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