HHH-16754 Add test for issue

This commit is contained in:
Marco Belladelli 2023-06-23 13:10:48 +02:00
parent 899bf1efa5
commit 1126438604
1 changed files with 30 additions and 0 deletions

View File

@ -16,6 +16,7 @@ import org.hibernate.testing.orm.domain.StandardDomainModel;
import org.hibernate.testing.orm.domain.gambit.EntityOfLists;
import org.hibernate.testing.orm.junit.DialectFeatureChecks;
import org.hibernate.testing.orm.junit.DomainModel;
import org.hibernate.testing.orm.junit.Jira;
import org.hibernate.testing.orm.junit.RequiresDialectFeature;
import org.hibernate.testing.orm.junit.ServiceRegistry;
import org.hibernate.testing.orm.junit.SessionFactory;
@ -160,4 +161,33 @@ public class SetOperationJpaCriteriaTest {
}
);
}
@Test
@RequiresDialectFeature(feature = DialectFeatureChecks.SupportsUnion.class)
@RequiresDialectFeature(feature = DialectFeatureChecks.SupportsOrderByInSubquery.class)
@Jira( "https://hibernate.atlassian.net/browse/HHH-16754" )
public void testUnionAllSubqueryOrderByPath(SessionFactoryScope scope) {
scope.inSession(
session -> {
HibernateCriteriaBuilder cb = session.getCriteriaBuilder();
JpaCriteriaQuery<EntityOfLists> query1 = cb.createQuery( EntityOfLists.class );
JpaRoot<EntityOfLists> root1 = query1.from( EntityOfLists.class );
query1.where( cb.equal( root1.get( "id" ), 1 ) );
JpaCriteriaQuery<EntityOfLists> query2 = cb.createQuery( EntityOfLists.class );
JpaRoot<EntityOfLists> root2 = query2.from( EntityOfLists.class );
query2.where( cb.equal( root2.get( "id" ), 2 ) );
List<EntityOfLists> list = session.createQuery(
cb.unionAll(
query1,
query2.orderBy( cb.asc( root2.get("name") ) )
.fetch( 1 )
)
).list();
assertThat( list.size(), is( 2 ) );
}
);
}
}