HHH-11383 - Added additional property projection test case.

(cherry picked from commit 89583fd008)
This commit is contained in:
Chris Cranford 2017-01-18 10:50:38 -05:00 committed by Gail Badner
parent 4729c2b13b
commit b19e831c93
1 changed files with 15 additions and 0 deletions

View File

@ -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)