From b19e831c937abc9314c6acac98f2b33296042b2a Mon Sep 17 00:00:00 2001 From: Chris Cranford Date: Wed, 18 Jan 2017 10:50:38 -0500 Subject: [PATCH] HHH-11383 - Added additional property projection test case. (cherry picked from commit 89583fd0089ee20cf51839bf3fc1caa8bf93d9cc) --- .../InheritanceAssociationToOneInnerJoinTest.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/hibernate-envers/src/test/java/org/hibernate/envers/test/integration/query/InheritanceAssociationToOneInnerJoinTest.java b/hibernate-envers/src/test/java/org/hibernate/envers/test/integration/query/InheritanceAssociationToOneInnerJoinTest.java index d98860b871..72da455a2c 100644 --- a/hibernate-envers/src/test/java/org/hibernate/envers/test/integration/query/InheritanceAssociationToOneInnerJoinTest.java +++ b/hibernate-envers/src/test/java/org/hibernate/envers/test/integration/query/InheritanceAssociationToOneInnerJoinTest.java @@ -110,6 +110,21 @@ public class InheritanceAssociationToOneInnerJoinTest extends BaseEnversJPAFunct assertEquals( 2, results.size() ); } + @Test + public void testAuditQueryWithJoinedInheritanceSubclassPropertyProjectionWithRelationTraversal() { + // HHH-11383 + // This test was requested by the reporter so that we have a test that shows Hibernate is + // automatically adding "INNER JOIN EntityA_AUD" despite the fact whether the query uses + // the traverseRelation API or not. This test makes sure that if the SQL generation is + // changed in the future, Envers would properly fail if so. + List results = getAuditReader().createQuery().forEntitiesAtRevision( EntityB.class, 1 ) + .addProjection( property( "name" ) ) + .traverseRelation( "relationToC", JoinType.INNER ) + .add( property( "foo" ).like( "bar" ) ) + .getResultList(); + assertEquals( 2, results.size() ); + } + @Entity(name = "EntityA") @Audited @Inheritance(strategy = InheritanceType.JOINED)