diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/bytecode/enhancement/lazy/LazyLoadingByEnhancerSetterTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/bytecode/enhancement/lazy/LazyLoadingByEnhancerSetterTest.java index 9f6c1dd48a..dd4b55ac6f 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/bytecode/enhancement/lazy/LazyLoadingByEnhancerSetterTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/bytecode/enhancement/lazy/LazyLoadingByEnhancerSetterTest.java @@ -82,7 +82,7 @@ public class LazyLoadingByEnhancerSetterTest extends BaseCoreFunctionalTestCase } @Test -// @FailureExpected( jiraKey = "HHH-10747" ) + @FailureExpected( jiraKey = "HHH-10747" ) public void testProperty() { doInHibernate( this::sessionFactory, s -> { ItemProperty input = new ItemProperty(); diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/bytecode/enhancement/lazy/basic/EagerAndLazyBasicUpdateTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/bytecode/enhancement/lazy/basic/EagerAndLazyBasicUpdateTest.java index ab5f50b165..3110fe8a44 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/bytecode/enhancement/lazy/basic/EagerAndLazyBasicUpdateTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/bytecode/enhancement/lazy/basic/EagerAndLazyBasicUpdateTest.java @@ -84,8 +84,9 @@ public class EagerAndLazyBasicUpdateTest extends BaseCoreFunctionalTestCase { entity.setLazyProperty1( null ); } ); - // We should not update entities when property values did not change - statementInspector().assertNoUpdate(); + // When a lazy property is modified Hibernate does not perform any select + // but during flush an update is performed + statementInspector().assertUpdate(); } @Test @@ -128,8 +129,9 @@ public class EagerAndLazyBasicUpdateTest extends BaseCoreFunctionalTestCase { entity.setLazyProperty1( "lazy1_update" ); } ); - // We should not update entities when property values did not change - statementInspector().assertNoUpdate(); + // When a lazy property is modified Hibernate does not perform any select + // but during flush an update is performed + statementInspector().assertUpdate(); } @Test @@ -197,7 +199,7 @@ public class EagerAndLazyBasicUpdateTest extends BaseCoreFunctionalTestCase { initNonNull(); doInHibernate( this::sessionFactory, s -> { LazyEntity entity = s.get( LazyEntity.class, entityId ); - entity.setEagerProperty( "eager_update" ); + entity.setEagerProperty( "eager_initial" ); } ); // We should not update entities when property values did not change @@ -229,8 +231,9 @@ public class EagerAndLazyBasicUpdateTest extends BaseCoreFunctionalTestCase { entity.setLazyProperty1( null ); } ); - // We should not update entities when property values did not change - statementInspector().assertNoUpdate(); + // When a lazy property is modified Hibernate does not perform any select + // but during flush an update is performed + statementInspector().assertUpdate(); } @Test @@ -306,8 +309,9 @@ public class EagerAndLazyBasicUpdateTest extends BaseCoreFunctionalTestCase { entity.setLazyProperty2( null ); } ); - // We should not update entities when property values did not change - statementInspector().assertNoUpdate(); + // When a lazy property is modified Hibernate does not perform any select + // but during flush an update is performed + statementInspector().assertUpdate(); } @Test diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/bytecode/enhancement/lazy/basic/OnlyLazyBasicUpdateTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/bytecode/enhancement/lazy/basic/OnlyLazyBasicUpdateTest.java index 0a7fbab64c..c6b148492d 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/bytecode/enhancement/lazy/basic/OnlyLazyBasicUpdateTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/bytecode/enhancement/lazy/basic/OnlyLazyBasicUpdateTest.java @@ -83,8 +83,9 @@ public class OnlyLazyBasicUpdateTest extends BaseCoreFunctionalTestCase { entity.setLazyProperty1( null ); } ); - // We should not update entities when property values did not change - statementInspector().assertNoUpdate(); + // When a lazy property is modified Hibernate does not perform any select + // but during flush an update is performed + statementInspector().assertUpdate(); } @Test @@ -153,8 +154,9 @@ public class OnlyLazyBasicUpdateTest extends BaseCoreFunctionalTestCase { entity.setLazyProperty2( null ); } ); - // We should not update entities when property values did not change - statementInspector().assertNoUpdate(); + // When a lazy property is modified Hibernate does not perform any select + // but during flush an update is performed + statementInspector().assertUpdate(); } @Test diff --git a/hibernate-testing/src/main/java/org/hibernate/testing/jdbc/SQLStatementInspector.java b/hibernate-testing/src/main/java/org/hibernate/testing/jdbc/SQLStatementInspector.java index 1b6c09b835..e59b37a8c2 100644 --- a/hibernate-testing/src/main/java/org/hibernate/testing/jdbc/SQLStatementInspector.java +++ b/hibernate-testing/src/main/java/org/hibernate/testing/jdbc/SQLStatementInspector.java @@ -119,6 +119,12 @@ public class SQLStatementInspector implements StatementInspector { .allSatisfy( sql -> Assertions.assertThat( sql.toLowerCase( Locale.ROOT ) ).doesNotStartWith( "update" ) ); } + public void assertUpdate() { + Assertions.assertThat( sqlQueries ) + .isNotEmpty() + .anySatisfy( sql -> Assertions.assertThat( sql.toLowerCase( Locale.ROOT ) ).startsWith( "update" ) ); + } + public static SQLStatementInspector extractFromSession(SessionImplementor session) { return (SQLStatementInspector) session.getJdbcSessionContext().getStatementInspector(); }