diff --git a/hibernate-envers/src/main/java/org/hibernate/envers/internal/entities/mapper/relation/component/MiddleEmbeddableComponentMapper.java b/hibernate-envers/src/main/java/org/hibernate/envers/internal/entities/mapper/relation/component/MiddleEmbeddableComponentMapper.java index 83ede336c5..f55901b134 100644 --- a/hibernate-envers/src/main/java/org/hibernate/envers/internal/entities/mapper/relation/component/MiddleEmbeddableComponentMapper.java +++ b/hibernate-envers/src/main/java/org/hibernate/envers/internal/entities/mapper/relation/component/MiddleEmbeddableComponentMapper.java @@ -105,7 +105,12 @@ public class MiddleEmbeddableComponentMapper implements MiddleComponentMapper, C ); } else { - parameters.addWhereOrNullRestriction(prefix1 + '.' + propertyName, false, "=", prefix2 + '.' + propertyName, false); + parameters.addWhereOrNullRestriction( + prefix1 + '.' + propertyName, + false, + "=", + prefix2 + '.' + propertyName, false + ); } } } diff --git a/hibernate-envers/src/main/java/org/hibernate/envers/internal/tools/query/Parameters.java b/hibernate-envers/src/main/java/org/hibernate/envers/internal/tools/query/Parameters.java index da444fec80..a285c87eb1 100644 --- a/hibernate-envers/src/main/java/org/hibernate/envers/internal/tools/query/Parameters.java +++ b/hibernate-envers/src/main/java/org/hibernate/envers/internal/tools/query/Parameters.java @@ -288,6 +288,7 @@ public class Parameters { /** * Add where clause with a null restriction: (left = right or (left is null and right is null)) + * * @param left Left property name. * @param addAliasLeft Whether to add the alias to the left property. * @param op The operator. diff --git a/hibernate-envers/src/test/java/org/hibernate/envers/test/integration/collection/embeddable/EmbeddableList3.java b/hibernate-envers/src/test/java/org/hibernate/envers/test/integration/collection/embeddable/EmbeddableList3.java index a0683e506e..38366ab14b 100644 --- a/hibernate-envers/src/test/java/org/hibernate/envers/test/integration/collection/embeddable/EmbeddableList3.java +++ b/hibernate-envers/src/test/java/org/hibernate/envers/test/integration/collection/embeddable/EmbeddableList3.java @@ -9,13 +9,12 @@ package org.hibernate.envers.test.integration.collection.embeddable; import org.hibernate.envers.test.BaseEnversJPAFunctionalTestCase; import org.hibernate.envers.test.Priority; import org.hibernate.envers.test.entities.StrTestNoProxyEntity; -import org.hibernate.envers.test.entities.collection.EmbeddableListEntity1; import org.hibernate.envers.test.entities.collection.EmbeddableListEntity3; import org.hibernate.envers.test.entities.components.relations.ManyToOneEagerComponent; import org.hibernate.testing.TestForIssue; +import org.hibernate.testing.transaction.TransactionUtil; import org.junit.Test; -import javax.persistence.EntityManager; import java.util.Arrays; import static org.junit.Assert.assertEquals; @@ -25,47 +24,32 @@ import static org.junit.Assert.assertEquals; */ @TestForIssue(jiraKey = "HHH-11364") public class EmbeddableList3 extends BaseEnversJPAFunctionalTestCase { - private Integer ele3_id = null; - - private ManyToOneEagerComponent component = new ManyToOneEagerComponent(null, "data"); - + private Integer ele3_id; @Override protected Class[] getAnnotatedClasses() { - return new Class[] {EmbeddableListEntity3.class, StrTestNoProxyEntity.class}; + return new Class[] { EmbeddableListEntity3.class, StrTestNoProxyEntity.class }; } @Test @Priority(10) public void initData() { - EntityManager em = getEntityManager(); - - EmbeddableListEntity3 ele3 = new EmbeddableListEntity3(); - - // Revision 1 (persist the entity ) - em.getTransaction().begin(); - ele3.getComponentList().add(component); - em.persist( ele3 ); - em.getTransaction().commit(); - - em.close(); - - ele3_id = ele3.getId(); - + ele3_id = TransactionUtil.doInJPA( this::entityManagerFactory, entityManager -> { + EmbeddableListEntity3 ele3 = new EmbeddableListEntity3(); + ele3.getComponentList().add( new ManyToOneEagerComponent( null, "data" ) ); + entityManager.persist( ele3 ); + return ele3.getId(); + } ); } @Test public void testRevisionsCounts() { - assertEquals( - Arrays.asList(1), getAuditReader().getRevisions( - EmbeddableListEntity3.class, - ele3_id) - ); + assertEquals( Arrays.asList( 1 ), getAuditReader().getRevisions( EmbeddableListEntity3.class, ele3_id) ); } @Test public void testCollectionOfEmbeddableWithNullJoinColumn() { final EmbeddableListEntity3 ele3 = getAuditReader().find( EmbeddableListEntity3.class, ele3_id, 1 ); - assertEquals("Expected there to be elements in the list", 1, ele3.getComponentList().size()); + assertEquals( "Expected there to be elements in the list", 1, ele3.getComponentList().size() ); } }