diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/cid/keymanytoone/EagerKeyManyToOneTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/cid/keymanytoone/EagerKeyManyToOneTest.java index 50ed94b5b4..5debcb78d4 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/cid/keymanytoone/EagerKeyManyToOneTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/cid/keymanytoone/EagerKeyManyToOneTest.java @@ -26,7 +26,7 @@ import static org.junit.jupiter.api.Assertions.fail; annotatedClasses = { Card.class, CardField.class, Key.class }) -@SessionFactory(statementInspectorClass = SQLStatementInspector.class) +@SessionFactory(useCollectingStatementInspector = true) public class EagerKeyManyToOneTest { public static final String CARD_ID = "cardId"; public static final String CARD_MODEL = "Gran Torino"; @@ -65,7 +65,7 @@ public class EagerKeyManyToOneTest { // meant to test against regression relating to http://opensource.atlassian.com/projects/hibernate/browse/HHH-2277 // and http://opensource.atlassian.com/projects/hibernate/browse/HHH-4147 - SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); + SQLStatementInspector statementInspector = scope.getCollectingStatementInspector(); statementInspector.clear(); scope.inTransaction( session -> { diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/cid/keymanytoone/association/EagerKeyManyToOneTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/cid/keymanytoone/association/EagerKeyManyToOneTest.java index bbbf30f2c6..4e96edeb3f 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/cid/keymanytoone/association/EagerKeyManyToOneTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/cid/keymanytoone/association/EagerKeyManyToOneTest.java @@ -24,7 +24,7 @@ import static org.junit.jupiter.api.Assertions.fail; annotatedClasses = { Card.class, CardField.class, Key.class }) -@SessionFactory(statementInspectorClass = SQLStatementInspector.class) +@SessionFactory(useCollectingStatementInspector = true) public class EagerKeyManyToOneTest { public static final String CARD_ID = "cardId"; public static final String KEY_ID = "keyId"; @@ -59,7 +59,7 @@ public class EagerKeyManyToOneTest { @Test public void testLoadEntityWithEagerFetchingToKeyManyToOneReferenceBackToSelf(SessionFactoryScope scope) { - SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); + SQLStatementInspector statementInspector = scope.getCollectingStatementInspector(); statementInspector.clear(); scope.inTransaction( session -> { diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/embedded/EmbeddableBiDirectionalSelfReferenceTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/embedded/EmbeddableBiDirectionalSelfReferenceTest.java index f337273b2e..23c511b5c5 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/embedded/EmbeddableBiDirectionalSelfReferenceTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/embedded/EmbeddableBiDirectionalSelfReferenceTest.java @@ -36,7 +36,7 @@ import static org.junit.jupiter.api.Assertions.assertSame; EntityTest.class } ) -@SessionFactory(statementInspectorClass = SQLStatementInspector.class) +@SessionFactory(useCollectingStatementInspector = true) public class EmbeddableBiDirectionalSelfReferenceTest { @BeforeEach @@ -70,7 +70,7 @@ public class EmbeddableBiDirectionalSelfReferenceTest { @Test public void testGet(SessionFactoryScope scope) { - SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); + SQLStatementInspector statementInspector = scope.getCollectingStatementInspector(); statementInspector.clear(); scope.inTransaction( session -> { @@ -111,7 +111,7 @@ public class EmbeddableBiDirectionalSelfReferenceTest { } ); - SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); + SQLStatementInspector statementInspector = scope.getCollectingStatementInspector(); statementInspector.clear(); scope.inTransaction( session -> { diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/embedded/EmbeddableWithManyToOneCircularityTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/embedded/EmbeddableWithManyToOneCircularityTest.java index 972f22e5cf..a288240f0c 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/embedded/EmbeddableWithManyToOneCircularityTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/embedded/EmbeddableWithManyToOneCircularityTest.java @@ -32,7 +32,7 @@ import static org.junit.jupiter.api.Assertions.assertSame; EmbeddableWithManyToOneCircularityTest.EntityTest2.class } ) -@SessionFactory(statementInspectorClass = SQLStatementInspector.class) +@SessionFactory(useCollectingStatementInspector = true) public class EmbeddableWithManyToOneCircularityTest { @BeforeEach @@ -76,7 +76,7 @@ public class EmbeddableWithManyToOneCircularityTest { @Test public void testGet(SessionFactoryScope scope) { - SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); + SQLStatementInspector statementInspector = scope.getCollectingStatementInspector(); statementInspector.clear(); scope.inTransaction( session -> { diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/embedded/EmbeddableWithManyToOneTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/embedded/EmbeddableWithManyToOneTest.java index 34a47a1f24..c4c00bce73 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/embedded/EmbeddableWithManyToOneTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/embedded/EmbeddableWithManyToOneTest.java @@ -34,7 +34,7 @@ import static org.junit.jupiter.api.Assertions.assertSame; EmbeddableWithManyToOneTest.EntityTest2.class } ) -@SessionFactory(statementInspectorClass = SQLStatementInspector.class) +@SessionFactory(useCollectingStatementInspector = true) public class EmbeddableWithManyToOneTest { @BeforeEach @@ -78,7 +78,7 @@ public class EmbeddableWithManyToOneTest { @Test public void testGet(SessionFactoryScope scope) { - SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); + SQLStatementInspector statementInspector = scope.getCollectingStatementInspector(); statementInspector.clear(); scope.inTransaction( session -> { @@ -112,7 +112,7 @@ public class EmbeddableWithManyToOneTest { session.save( entityTest2 ); } ); - SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); + SQLStatementInspector statementInspector = scope.getCollectingStatementInspector(); statementInspector.clear(); scope.inTransaction( session -> { @@ -152,7 +152,7 @@ public class EmbeddableWithManyToOneTest { session.save( entityTest2 ); } ); - SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); + SQLStatementInspector statementInspector = scope.getCollectingStatementInspector(); statementInspector.clear(); scope.inTransaction( session -> { diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/manytoone/NotOptionalManyToOneTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/manytoone/NotOptionalManyToOneTest.java index c7cd2e4cf7..ba67db48eb 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/manytoone/NotOptionalManyToOneTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/manytoone/NotOptionalManyToOneTest.java @@ -31,7 +31,7 @@ import org.junit.jupiter.api.Test; Child.class } ) -@SessionFactory(statementInspectorClass = SQLStatementInspector.class) +@SessionFactory(useCollectingStatementInspector = true) public class NotOptionalManyToOneTest { @BeforeEach @@ -59,7 +59,7 @@ public class NotOptionalManyToOneTest { @Test public void testInnerJoinIsUsed(SessionFactoryScope scope) { - SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); + SQLStatementInspector statementInspector = scope.getCollectingStatementInspector(); statementInspector.clear(); scope.inTransaction( session -> { diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/onetomany/OneToManyJoinColumnsUniquenessTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/onetomany/OneToManyJoinColumnsUniquenessTest.java index 3474d09e23..22abe3f04b 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/onetomany/OneToManyJoinColumnsUniquenessTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/onetomany/OneToManyJoinColumnsUniquenessTest.java @@ -28,13 +28,13 @@ import static org.junit.jupiter.api.Assertions.assertThrows; OneToManyJoinColumnsUniquenessTest.EntityB.class, } ) -@SessionFactory(statementInspectorClass = SQLStatementInspector.class) +@SessionFactory(useCollectingStatementInspector = true) @TestForIssue(jiraKey = "HHH-15091") public class OneToManyJoinColumnsUniquenessTest { @Test public void testInsertWithNullAssociationThrowPersistenceException(SessionFactoryScope scope) { - SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); + SQLStatementInspector statementInspector = scope.getCollectingStatementInspector(); statementInspector.clear(); assertThrows( PersistenceException.class, () -> diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/query/QueryListParametersWithFetchSubSelectTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/query/QueryListParametersWithFetchSubSelectTest.java index 4eaaa887cc..a295e3dcc4 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/query/QueryListParametersWithFetchSubSelectTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/query/QueryListParametersWithFetchSubSelectTest.java @@ -20,7 +20,6 @@ import org.hibernate.testing.orm.junit.DomainModel; import org.hibernate.testing.orm.junit.SessionFactory; import org.hibernate.testing.orm.junit.SessionFactoryScope; import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import jakarta.persistence.Entity; @@ -44,7 +43,7 @@ import static org.assertj.core.api.Assertions.assertThat; } ) @SessionFactory( - statementInspectorClass = SQLStatementInspector.class + useCollectingStatementInspector = true ) public class QueryListParametersWithFetchSubSelectTest { @@ -65,7 +64,7 @@ public class QueryListParametersWithFetchSubSelectTest { @Test public void simpleTest(SessionFactoryScope scope) { - final SQLStatementInspector sqlStatementInterceptor = (SQLStatementInspector) scope.getStatementInspector(); + final SQLStatementInspector sqlStatementInterceptor = scope.getCollectingStatementInspector(); sqlStatementInterceptor.clear(); scope.inTransaction( s -> { @@ -85,7 +84,7 @@ public class QueryListParametersWithFetchSubSelectTest { @Test @TestForIssue(jiraKey = "HHH-14439") public void reusingQueryWithFewerNamedParameters(SessionFactoryScope scope) { - final SQLStatementInspector sqlStatementInterceptor = (SQLStatementInspector) scope.getStatementInspector(); + final SQLStatementInspector sqlStatementInterceptor = scope.getCollectingStatementInspector(); sqlStatementInterceptor.clear(); @@ -120,7 +119,7 @@ public class QueryListParametersWithFetchSubSelectTest { @Test @TestForIssue(jiraKey = "HHH-14439") public void reusingQueryWithFewerOrdinalParameters(SessionFactoryScope scope) { - final SQLStatementInspector sqlStatementInterceptor = (SQLStatementInspector) scope.getStatementInspector(); + final SQLStatementInspector sqlStatementInterceptor = scope.getCollectingStatementInspector(); sqlStatementInterceptor.clear(); diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/batch/BatchNoUseJdbcMetadataTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/batch/BatchNoUseJdbcMetadataTest.java index 0ddbcc030b..78c213b8b4 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/batch/BatchNoUseJdbcMetadataTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/batch/BatchNoUseJdbcMetadataTest.java @@ -22,7 +22,7 @@ import static org.assertj.core.api.AssertionsForClassTypes.assertThat; @DomainModel( annotatedClasses = BatchNoUseJdbcMetadataTest.Person.class ) -@SessionFactory(statementInspectorClass = SQLStatementInspector.class) +@SessionFactory(useCollectingStatementInspector = true) @ServiceRegistry( settings = { @Setting(name = AvailableSettings.STATEMENT_BATCH_SIZE, value = "5"), @@ -35,7 +35,7 @@ public class BatchNoUseJdbcMetadataTest { @Test public void testBatching(SessionFactoryScope scope) { - final SQLStatementInspector sqlStatementInterceptor = (SQLStatementInspector) scope.getStatementInspector(); + final SQLStatementInspector sqlStatementInterceptor = scope.getCollectingStatementInspector(); sqlStatementInterceptor.clear(); scope.inTransaction( session -> { diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/batch/EagerManyToOneBatchTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/batch/EagerManyToOneBatchTest.java index 808575dcb3..892305521a 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/batch/EagerManyToOneBatchTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/batch/EagerManyToOneBatchTest.java @@ -30,7 +30,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; EagerManyToOneBatchTest.Parent.class } ) -@SessionFactory(statementInspectorClass = SQLStatementInspector.class) +@SessionFactory(useCollectingStatementInspector = true) @ServiceRegistry( settings = @Setting(name = AvailableSettings.DEFAULT_BATCH_FETCH_SIZE, value = "2") ) @@ -67,7 +67,7 @@ public class EagerManyToOneBatchTest { @Test public void testSelect(SessionFactoryScope scope) { - SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); + SQLStatementInspector statementInspector = scope.getCollectingStatementInspector(); statementInspector.clear(); scope.inTransaction( session -> { diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/batch/LazyManyToOneBatchTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/batch/LazyManyToOneBatchTest.java index 70f24840d5..23492f0c83 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/batch/LazyManyToOneBatchTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/batch/LazyManyToOneBatchTest.java @@ -31,7 +31,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; LazyManyToOneBatchTest.Parent.class } ) -@SessionFactory(statementInspectorClass = SQLStatementInspector.class) +@SessionFactory(useCollectingStatementInspector = true) @ServiceRegistry( settings = @Setting(name = AvailableSettings.DEFAULT_BATCH_FETCH_SIZE, value = "2") ) @@ -67,7 +67,7 @@ public class LazyManyToOneBatchTest { @Test public void testSelect(SessionFactoryScope scope) { - SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); + SQLStatementInspector statementInspector = scope.getCollectingStatementInspector(); statementInspector.clear(); scope.inTransaction( session -> { diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/batchfetch/EagerManyToOneStreamTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/batchfetch/EagerManyToOneStreamTest.java index 30af36fd78..885038cb33 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/batchfetch/EagerManyToOneStreamTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/batchfetch/EagerManyToOneStreamTest.java @@ -38,7 +38,7 @@ import static org.assertj.core.api.AssertionsForClassTypes.assertThat; @DomainModel( annotatedClasses = { EagerManyToOneStreamTest.Child.class, EagerManyToOneStreamTest.Parent.class } ) -@SessionFactory(statementInspectorClass = SQLStatementInspector.class) +@SessionFactory(useCollectingStatementInspector = true) @ServiceRegistry(settings = @Setting(name = AvailableSettings.DEFAULT_BATCH_FETCH_SIZE, value = "2")) @JiraKey("HHH-15449") public class EagerManyToOneStreamTest { @@ -72,7 +72,7 @@ public class EagerManyToOneStreamTest { @Test public void testGetResultStreamCollectSingleResult(SessionFactoryScope scope) { - final SQLStatementInspector sqlStatementInterceptor = (SQLStatementInspector) scope.getStatementInspector(); + final SQLStatementInspector sqlStatementInterceptor = scope.getCollectingStatementInspector(); sqlStatementInterceptor.clear(); scope.inTransaction( session -> { @@ -100,7 +100,7 @@ public class EagerManyToOneStreamTest { @Test public void testGetResultStreamCollect(SessionFactoryScope scope) { - final SQLStatementInspector sqlStatementInterceptor = (SQLStatementInspector) scope.getStatementInspector(); + final SQLStatementInspector sqlStatementInterceptor = scope.getCollectingStatementInspector(); sqlStatementInterceptor.clear(); scope.inTransaction( session -> { diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/batchfetch/EagerManyToOneTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/batchfetch/EagerManyToOneTest.java index 758b8c563d..5d5ec7fe00 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/batchfetch/EagerManyToOneTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/batchfetch/EagerManyToOneTest.java @@ -35,7 +35,7 @@ import static org.assertj.core.api.AssertionsForClassTypes.assertThat; @DomainModel( annotatedClasses = { EagerManyToOneTest.Child.class, EagerManyToOneTest.Parent.class } ) -@SessionFactory(statementInspectorClass = SQLStatementInspector.class) +@SessionFactory(useCollectingStatementInspector = true) @ServiceRegistry(settings = @Setting(name = AvailableSettings.DEFAULT_BATCH_FETCH_SIZE, value = "2")) @JiraKey("HHH-15449") public class EagerManyToOneTest { @@ -69,7 +69,7 @@ public class EagerManyToOneTest { @Test public void testGetResultList(SessionFactoryScope scope) { - final SQLStatementInspector sqlStatementInterceptor = (SQLStatementInspector) scope.getStatementInspector(); + final SQLStatementInspector sqlStatementInterceptor = scope.getCollectingStatementInspector(); sqlStatementInterceptor.clear(); scope.inTransaction( session -> { diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/batchfetch/LazyManyToOneStreamTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/batchfetch/LazyManyToOneStreamTest.java index 3b46540fc3..419786838a 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/batchfetch/LazyManyToOneStreamTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/batchfetch/LazyManyToOneStreamTest.java @@ -39,7 +39,7 @@ import static org.assertj.core.api.AssertionsForClassTypes.assertThat; @DomainModel( annotatedClasses = { LazyManyToOneStreamTest.Child.class, LazyManyToOneStreamTest.Parent.class } ) -@SessionFactory( statementInspectorClass = SQLStatementInspector.class) +@SessionFactory( useCollectingStatementInspector = true) @ServiceRegistry(settings = @Setting(name = AvailableSettings.DEFAULT_BATCH_FETCH_SIZE, value = "2")) @JiraKey("HHH-15449") public class LazyManyToOneStreamTest { @@ -73,7 +73,7 @@ public class LazyManyToOneStreamTest { @Test public void testGetResultStreamCollectSingleResult(SessionFactoryScope scope) { - final SQLStatementInspector sqlStatementInterceptor = (SQLStatementInspector) scope.getStatementInspector(); + final SQLStatementInspector sqlStatementInterceptor = scope.getCollectingStatementInspector(); sqlStatementInterceptor.clear(); scope.inTransaction( session -> { @@ -100,7 +100,7 @@ public class LazyManyToOneStreamTest { @Test public void testGetResultStreamCollect(SessionFactoryScope scope) { - final SQLStatementInspector sqlStatementInterceptor = (SQLStatementInspector) scope.getStatementInspector(); + final SQLStatementInspector sqlStatementInterceptor = scope.getCollectingStatementInspector(); sqlStatementInterceptor.clear(); scope.inTransaction( session -> { diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/batchfetch/LazyManyToOneTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/batchfetch/LazyManyToOneTest.java index 6cb36cb6da..a800879318 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/batchfetch/LazyManyToOneTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/batchfetch/LazyManyToOneTest.java @@ -36,7 +36,7 @@ import static org.assertj.core.api.AssertionsForClassTypes.assertThat; @DomainModel( annotatedClasses = { LazyManyToOneTest.Child.class, LazyManyToOneTest.Parent.class } ) -@SessionFactory(statementInspectorClass = SQLStatementInspector.class) +@SessionFactory(useCollectingStatementInspector = true) @ServiceRegistry(settings = @Setting(name = AvailableSettings.DEFAULT_BATCH_FETCH_SIZE, value = "2")) @JiraKey("HHH-15449") public class LazyManyToOneTest { @@ -70,7 +70,7 @@ public class LazyManyToOneTest { @Test public void testGetResultList(SessionFactoryScope scope) { - final SQLStatementInspector sqlStatementInterceptor = (SQLStatementInspector) scope.getStatementInspector(); + final SQLStatementInspector sqlStatementInterceptor = scope.getCollectingStatementInspector(); sqlStatementInterceptor.clear(); scope.inTransaction( session -> { diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/cascade/CascadeMergeToProxyEntityCopyAllowedTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/cascade/CascadeMergeToProxyEntityCopyAllowedTest.java index 7b658326b9..2f38f4a78e 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/cascade/CascadeMergeToProxyEntityCopyAllowedTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/cascade/CascadeMergeToProxyEntityCopyAllowedTest.java @@ -39,7 +39,6 @@ import org.hibernate.testing.orm.junit.Setting; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import static org.hibernate.testing.transaction.TransactionUtil.doInHibernate; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; @@ -52,7 +51,7 @@ import static org.junit.jupiter.api.Assertions.assertNotNull; CascadeMergeToProxyEntityCopyAllowedTest.Speaker.class } ) -@SessionFactory(statementInspectorClass = SQLStatementInspector.class) +@SessionFactory(useCollectingStatementInspector = true) @ServiceRegistry( settings = { @Setting( @@ -67,7 +66,7 @@ public class CascadeMergeToProxyEntityCopyAllowedTest { public void test(SessionFactoryScope scope) { final Event root = (Event) persistEntity( scope, new Event( null, defaultProject ) ); - SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); + SQLStatementInspector statementInspector = scope.getCollectingStatementInspector(); statementInspector.clear(); Event rootFromDB = scope.fromTransaction( session -> { diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/cid/CompositeIdTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/cid/CompositeIdTest.java index ed840025b0..0720eee697 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/cid/CompositeIdTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/cid/CompositeIdTest.java @@ -35,7 +35,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue; "org/hibernate/orm/test/cid/Product.hbm.xml" } ) -@SessionFactory(statementInspectorClass = SQLStatementInspector.class) +@SessionFactory(useCollectingStatementInspector = true) public class CompositeIdTest { @AfterEach @@ -90,7 +90,7 @@ public class CompositeIdTest { } ); - final SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); + final SQLStatementInspector statementInspector = scope.getCollectingStatementInspector(); statementInspector.clear(); scope.inTransaction( diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/compositefk/EagerManyToOneEmbeddedIdFKTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/compositefk/EagerManyToOneEmbeddedIdFKTest.java index a43d61552e..2f971e1ed6 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/compositefk/EagerManyToOneEmbeddedIdFKTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/compositefk/EagerManyToOneEmbeddedIdFKTest.java @@ -17,7 +17,6 @@ import jakarta.persistence.Table; import org.hibernate.testing.jdbc.SQLStatementInspector; import org.hibernate.testing.orm.junit.DomainModel; -import org.hibernate.testing.orm.junit.FailureExpected; import org.hibernate.testing.orm.junit.SessionFactory; import org.hibernate.testing.orm.junit.SessionFactoryScope; import org.junit.jupiter.api.AfterEach; @@ -37,7 +36,7 @@ import static org.hamcrest.core.IsNull.notNullValue; EagerManyToOneEmbeddedIdFKTest.SystemUser.class } ) -@SessionFactory(statementInspectorClass = SQLStatementInspector.class) +@SessionFactory(useCollectingStatementInspector = true) public class EagerManyToOneEmbeddedIdFKTest { @BeforeEach @@ -68,7 +67,7 @@ public class EagerManyToOneEmbeddedIdFKTest { @Test public void testGet(SessionFactoryScope scope) { - SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); + SQLStatementInspector statementInspector = scope.getCollectingStatementInspector(); statementInspector.clear(); scope.inTransaction( session -> { @@ -84,7 +83,7 @@ public class EagerManyToOneEmbeddedIdFKTest { @Test public void testHql(SessionFactoryScope scope) { - SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); + SQLStatementInspector statementInspector = scope.getCollectingStatementInspector(); statementInspector.clear(); scope.inTransaction( session -> { diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/compositefk/LazyManyToOneEmbeddedIdWithToOneFKTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/compositefk/LazyManyToOneEmbeddedIdWithToOneFKTest.java index cee45214c6..e20e114450 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/compositefk/LazyManyToOneEmbeddedIdWithToOneFKTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/compositefk/LazyManyToOneEmbeddedIdWithToOneFKTest.java @@ -42,7 +42,7 @@ import static org.junit.jupiter.api.Assertions.assertFalse; LazyManyToOneEmbeddedIdWithToOneFKTest.Subsystem.class } ) -@SessionFactory(statementInspectorClass = SQLStatementInspector.class) +@SessionFactory(useCollectingStatementInspector = true) public class LazyManyToOneEmbeddedIdWithToOneFKTest { @BeforeEach @@ -76,7 +76,7 @@ public class LazyManyToOneEmbeddedIdWithToOneFKTest { @Test public void testGet(SessionFactoryScope scope) { - SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); + SQLStatementInspector statementInspector = scope.getCollectingStatementInspector(); statementInspector.clear(); scope.inTransaction( session -> { @@ -116,7 +116,7 @@ public class LazyManyToOneEmbeddedIdWithToOneFKTest { @Test public void testHql(SessionFactoryScope scope) { - SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); + SQLStatementInspector statementInspector = scope.getCollectingStatementInspector(); statementInspector.clear(); scope.inTransaction( session -> { @@ -155,7 +155,7 @@ public class LazyManyToOneEmbeddedIdWithToOneFKTest { @Test public void testHqlJoin(SessionFactoryScope scope) { - SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); + SQLStatementInspector statementInspector = scope.getCollectingStatementInspector(); statementInspector.clear(); scope.inTransaction( session -> { @@ -176,7 +176,7 @@ public class LazyManyToOneEmbeddedIdWithToOneFKTest { @Test public void testHqlJoinFetch(SessionFactoryScope scope) { - SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); + SQLStatementInspector statementInspector = scope.getCollectingStatementInspector(); statementInspector.clear(); scope.inTransaction( session -> { @@ -201,7 +201,7 @@ public class LazyManyToOneEmbeddedIdWithToOneFKTest { @Test public void testHql2(SessionFactoryScope scope) { - SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); + SQLStatementInspector statementInspector = scope.getCollectingStatementInspector(); statementInspector.clear(); scope.inTransaction( session -> { diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/compositefk/ManyToOneEmbeddedIdWithLazyToOneFKTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/compositefk/ManyToOneEmbeddedIdWithLazyToOneFKTest.java index a0eeac5f53..218c14caaf 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/compositefk/ManyToOneEmbeddedIdWithLazyToOneFKTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/compositefk/ManyToOneEmbeddedIdWithLazyToOneFKTest.java @@ -42,7 +42,7 @@ import static org.junit.Assert.assertTrue; ManyToOneEmbeddedIdWithLazyToOneFKTest.Subsystem.class } ) -@SessionFactory(statementInspectorClass = SQLStatementInspector.class) +@SessionFactory(useCollectingStatementInspector = true) public class ManyToOneEmbeddedIdWithLazyToOneFKTest { @BeforeEach @@ -76,7 +76,7 @@ public class ManyToOneEmbeddedIdWithLazyToOneFKTest { @Test public void testGet(SessionFactoryScope scope) { - SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); + SQLStatementInspector statementInspector = scope.getCollectingStatementInspector(); statementInspector.clear(); scope.inTransaction( session -> { @@ -110,7 +110,7 @@ public class ManyToOneEmbeddedIdWithLazyToOneFKTest { @Test public void testHql(SessionFactoryScope scope) { - SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); + SQLStatementInspector statementInspector = scope.getCollectingStatementInspector(); statementInspector.clear(); /* select @@ -169,7 +169,7 @@ public class ManyToOneEmbeddedIdWithLazyToOneFKTest { @Test public void testHqlJoin(SessionFactoryScope scope) { - SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); + SQLStatementInspector statementInspector = scope.getCollectingStatementInspector(); statementInspector.clear(); scope.inTransaction( session -> { @@ -203,7 +203,7 @@ public class ManyToOneEmbeddedIdWithLazyToOneFKTest { @Test public void testHqlJoinFetch(SessionFactoryScope scope) { - SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); + SQLStatementInspector statementInspector = scope.getCollectingStatementInspector(); statementInspector.clear(); scope.inTransaction( session -> { @@ -236,7 +236,7 @@ public class ManyToOneEmbeddedIdWithLazyToOneFKTest { @Test public void testHql2(SessionFactoryScope scope) { - SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); + SQLStatementInspector statementInspector = scope.getCollectingStatementInspector(); statementInspector.clear(); scope.inTransaction( session -> { diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/compositefk/ManyToOneEmbeddedIdWithToOneFKTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/compositefk/ManyToOneEmbeddedIdWithToOneFKTest.java index c64096bb82..5db575a114 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/compositefk/ManyToOneEmbeddedIdWithToOneFKTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/compositefk/ManyToOneEmbeddedIdWithToOneFKTest.java @@ -40,12 +40,12 @@ import static org.junit.Assert.assertTrue; ManyToOneEmbeddedIdWithToOneFKTest.DataCenter.class } ) -@SessionFactory(statementInspectorClass = SQLStatementInspector.class) +@SessionFactory(useCollectingStatementInspector = true) public class ManyToOneEmbeddedIdWithToOneFKTest { @Test public void testGet(SessionFactoryScope scope) { - SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); + SQLStatementInspector statementInspector = scope.getCollectingStatementInspector(); statementInspector.clear(); scope.inTransaction( session -> { @@ -75,7 +75,7 @@ public class ManyToOneEmbeddedIdWithToOneFKTest { @Test public void testHql(SessionFactoryScope scope) { - SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); + SQLStatementInspector statementInspector = scope.getCollectingStatementInspector(); statementInspector.clear(); scope.inTransaction( session -> { @@ -110,7 +110,7 @@ public class ManyToOneEmbeddedIdWithToOneFKTest { @Test public void testHqlJoin(SessionFactoryScope scope) { - SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); + SQLStatementInspector statementInspector = scope.getCollectingStatementInspector(); statementInspector.clear(); scope.inTransaction( session -> { @@ -129,7 +129,7 @@ public class ManyToOneEmbeddedIdWithToOneFKTest { @Test public void testHqlJoinFetch(SessionFactoryScope scope) { - SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); + SQLStatementInspector statementInspector = scope.getCollectingStatementInspector(); statementInspector.clear(); scope.inTransaction( session -> { @@ -168,7 +168,7 @@ public class ManyToOneEmbeddedIdWithToOneFKTest { @Test public void testHql2(SessionFactoryScope scope) { - SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); + SQLStatementInspector statementInspector = scope.getCollectingStatementInspector(); statementInspector.clear(); scope.inTransaction( session -> { diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/entitygraph/EntityGraphWithFetchAnnotationTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/entitygraph/EntityGraphWithFetchAnnotationTest.java index 86450e0694..4bf84c5796 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/entitygraph/EntityGraphWithFetchAnnotationTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/entitygraph/EntityGraphWithFetchAnnotationTest.java @@ -41,13 +41,13 @@ import static org.hamcrest.MatcherAssert.assertThat; EntityGraphWithFetchAnnotationTest.Tag.class } ) -@SessionFactory(statementInspectorClass = SQLStatementInspector.class) +@SessionFactory(useCollectingStatementInspector = true) public class EntityGraphWithFetchAnnotationTest { @Test @TestForIssue(jiraKey = "HHH-10485") void testWithoutEntityGraph(SessionFactoryScope scope) { - SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); + SQLStatementInspector statementInspector = scope.getCollectingStatementInspector(); statementInspector.clear(); scope.inTransaction( @@ -73,7 +73,7 @@ public class EntityGraphWithFetchAnnotationTest { @Test @TestForIssue(jiraKey = "HHH-10485") void testWithEntityGraph(SessionFactoryScope scope) { - SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); + SQLStatementInspector statementInspector = scope.getCollectingStatementInspector(); statementInspector.clear(); scope.inTransaction( diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/entitygraph/LoadAndFetchGraphTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/entitygraph/LoadAndFetchGraphTest.java index fd365864cb..25e579a4d9 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/entitygraph/LoadAndFetchGraphTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/entitygraph/LoadAndFetchGraphTest.java @@ -43,7 +43,7 @@ import static org.hibernate.testing.hamcrest.InitializationCheckMatcher.isNotIni LoadAndFetchGraphTest.EEntity.class } ) -@SessionFactory(statementInspectorClass = SQLStatementInspector.class) +@SessionFactory(useCollectingStatementInspector = true) @TestForIssue(jiraKey = "HHH-14097") public class LoadAndFetchGraphTest { @@ -171,7 +171,7 @@ public class LoadAndFetchGraphTest { @Test void testQueryById(SessionFactoryScope scope) { - SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); + SQLStatementInspector statementInspector = scope.getCollectingStatementInspector(); statementInspector.clear(); scope.inTransaction( session -> { @@ -195,7 +195,7 @@ public class LoadAndFetchGraphTest { @Test void testQueryByIdWithLoadGraph(SessionFactoryScope scope) { - SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); + SQLStatementInspector statementInspector = scope.getCollectingStatementInspector(); statementInspector.clear(); scope.inTransaction( session -> { @@ -226,7 +226,7 @@ public class LoadAndFetchGraphTest { @Test void testQueryByIdWithFetchGraph(SessionFactoryScope scope) { - SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); + SQLStatementInspector statementInspector = scope.getCollectingStatementInspector(); statementInspector.clear(); scope.inTransaction( session -> { @@ -256,7 +256,7 @@ public class LoadAndFetchGraphTest { @Test void testQueryByIdWithFetchGraph2(SessionFactoryScope scope) { - SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); + SQLStatementInspector statementInspector = scope.getCollectingStatementInspector(); statementInspector.clear(); scope.inTransaction( session -> { diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/fetch/ElementCollectionWithSubselectFetchModeTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/fetch/ElementCollectionWithSubselectFetchModeTest.java index d391495677..23fb63f427 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/fetch/ElementCollectionWithSubselectFetchModeTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/fetch/ElementCollectionWithSubselectFetchModeTest.java @@ -41,7 +41,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue; ElementCollectionWithSubselectFetchModeTest.Client.class } ) -@SessionFactory(statementInspectorClass = SQLStatementInspector.class) +@SessionFactory(useCollectingStatementInspector = true) @TestForIssue(jiraKey = "HHH-15640") public class ElementCollectionWithSubselectFetchModeTest { @@ -62,7 +62,7 @@ public class ElementCollectionWithSubselectFetchModeTest { @Test public void testSelect(SessionFactoryScope scope) { - SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); + SQLStatementInspector statementInspector = scope.getCollectingStatementInspector(); statementInspector.clear(); scope.inTransaction( session -> { diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/fetchmode/toone/EagerToOneWithJoinFetchModeTests.java b/hibernate-core/src/test/java/org/hibernate/orm/test/fetchmode/toone/EagerToOneWithJoinFetchModeTests.java index 4f1db9369f..522956bf61 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/fetchmode/toone/EagerToOneWithJoinFetchModeTests.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/fetchmode/toone/EagerToOneWithJoinFetchModeTests.java @@ -46,7 +46,7 @@ import static org.hamcrest.MatcherAssert.assertThat; EagerToOneWithJoinFetchModeTests.SimpleEntity.class } ) -@SessionFactory(statementInspectorClass = SQLStatementInspector.class) +@SessionFactory(useCollectingStatementInspector = true) @ServiceRegistry( settings = { @Setting(name = AvailableSettings.HBM2DDL_DATABASE_ACTION, value = "create-drop") @@ -79,7 +79,7 @@ public class EagerToOneWithJoinFetchModeTests { @Test public void testFind(SessionFactoryScope scope) { - SQLStatementInspector sqlStatementInterceptor = (SQLStatementInspector) scope.getStatementInspector(); + SQLStatementInspector sqlStatementInterceptor = scope.getCollectingStatementInspector(); scope.inTransaction( session -> { sqlStatementInterceptor.clear(); @@ -103,7 +103,7 @@ public class EagerToOneWithJoinFetchModeTests { @Test public void testHql(SessionFactoryScope scope) { - SQLStatementInspector sqlStatementInterceptor = (SQLStatementInspector) scope.getStatementInspector(); + SQLStatementInspector sqlStatementInterceptor = scope.getCollectingStatementInspector(); scope.inTransaction( session -> { sqlStatementInterceptor.clear(); @@ -133,7 +133,7 @@ public class EagerToOneWithJoinFetchModeTests { @Test public void testHqlJoinManyToOne(SessionFactoryScope scope) { - SQLStatementInspector sqlStatementInterceptor = (SQLStatementInspector) scope.getStatementInspector(); + SQLStatementInspector sqlStatementInterceptor = scope.getCollectingStatementInspector(); scope.inTransaction( session -> { sqlStatementInterceptor.clear(); @@ -165,7 +165,7 @@ public class EagerToOneWithJoinFetchModeTests { @Test public void testHqlJoinOneToOne(SessionFactoryScope scope) { - SQLStatementInspector sqlStatementInterceptor = (SQLStatementInspector) scope.getStatementInspector(); + SQLStatementInspector sqlStatementInterceptor = scope.getCollectingStatementInspector(); scope.inTransaction( session -> { sqlStatementInterceptor.clear(); @@ -198,7 +198,7 @@ public class EagerToOneWithJoinFetchModeTests { @Test public void testHqlJoinFetchManyToOne(SessionFactoryScope scope) { - SQLStatementInspector sqlStatementInterceptor = (SQLStatementInspector) scope.getStatementInspector(); + SQLStatementInspector sqlStatementInterceptor = scope.getCollectingStatementInspector(); scope.inTransaction( session -> { sqlStatementInterceptor.clear(); @@ -228,7 +228,7 @@ public class EagerToOneWithJoinFetchModeTests { @Test public void testHqlJoinFetchOneToOne(SessionFactoryScope scope) { - SQLStatementInspector sqlStatementInterceptor = (SQLStatementInspector) scope.getStatementInspector(); + SQLStatementInspector sqlStatementInterceptor = scope.getCollectingStatementInspector(); scope.inTransaction( session -> { sqlStatementInterceptor.clear(); @@ -258,7 +258,7 @@ public class EagerToOneWithJoinFetchModeTests { @Test public void testHqlJoinManyToOneAndOneToOne(SessionFactoryScope scope) { - SQLStatementInspector sqlStatementInterceptor = (SQLStatementInspector) scope.getStatementInspector(); + SQLStatementInspector sqlStatementInterceptor = scope.getCollectingStatementInspector(); scope.inTransaction( session -> { sqlStatementInterceptor.clear(); diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/fetchmode/toone/EagerToOneWithSelectFetchModeTests.java b/hibernate-core/src/test/java/org/hibernate/orm/test/fetchmode/toone/EagerToOneWithSelectFetchModeTests.java index ecc8b61cfe..a391fca005 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/fetchmode/toone/EagerToOneWithSelectFetchModeTests.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/fetchmode/toone/EagerToOneWithSelectFetchModeTests.java @@ -16,17 +16,13 @@ import jakarta.persistence.Table; import org.hibernate.Hibernate; import org.hibernate.annotations.Fetch; import org.hibernate.annotations.FetchMode; -import org.hibernate.boot.SessionFactoryBuilder; -import org.hibernate.boot.spi.MetadataImplementor; import org.hibernate.cfg.AvailableSettings; -import org.hibernate.engine.spi.SessionFactoryImplementor; import org.hibernate.sql.ast.SqlAstJoinType; import org.hibernate.testing.jdbc.SQLStatementInspector; import org.hibernate.testing.orm.junit.DomainModel; import org.hibernate.testing.orm.junit.ServiceRegistry; import org.hibernate.testing.orm.junit.SessionFactory; -import org.hibernate.testing.orm.junit.SessionFactoryProducer; import org.hibernate.testing.orm.junit.SessionFactoryScope; import org.hibernate.testing.orm.junit.Setting; import org.junit.jupiter.api.AfterEach; @@ -47,7 +43,7 @@ import static org.hamcrest.MatcherAssert.assertThat; EagerToOneWithSelectFetchModeTests.SimpleEntity.class } ) -@SessionFactory(statementInspectorClass = SQLStatementInspector.class) +@SessionFactory(useCollectingStatementInspector = true) @ServiceRegistry( settings = { @Setting(name = AvailableSettings.HBM2DDL_DATABASE_ACTION, value = "create-drop") @@ -72,7 +68,7 @@ public class EagerToOneWithSelectFetchModeTests { @Test public void testFind(SessionFactoryScope scope) { - SQLStatementInspector sqlStatementInterceptor = (SQLStatementInspector) scope.getStatementInspector(); + SQLStatementInspector sqlStatementInterceptor = scope.getCollectingStatementInspector(); scope.inTransaction( session -> { sqlStatementInterceptor.clear(); @@ -92,7 +88,7 @@ public class EagerToOneWithSelectFetchModeTests { @Test public void testHql(SessionFactoryScope scope) { - SQLStatementInspector sqlStatementInterceptor = (SQLStatementInspector) scope.getStatementInspector(); + SQLStatementInspector sqlStatementInterceptor = scope.getCollectingStatementInspector(); scope.inTransaction( session -> { sqlStatementInterceptor.clear(); @@ -124,7 +120,7 @@ public class EagerToOneWithSelectFetchModeTests { @Test public void testHqlJoinManyToOne(SessionFactoryScope scope) { - SQLStatementInspector sqlStatementInterceptor = (SQLStatementInspector) scope.getStatementInspector(); + SQLStatementInspector sqlStatementInterceptor = scope.getCollectingStatementInspector(); scope.inTransaction( session -> { sqlStatementInterceptor.clear(); @@ -158,7 +154,7 @@ public class EagerToOneWithSelectFetchModeTests { @Test public void testHqlJoinOneToOne(SessionFactoryScope scope) { - SQLStatementInspector sqlStatementInterceptor = (SQLStatementInspector) scope.getStatementInspector(); + SQLStatementInspector sqlStatementInterceptor = scope.getCollectingStatementInspector(); scope.inTransaction( session -> { sqlStatementInterceptor.clear(); @@ -192,7 +188,7 @@ public class EagerToOneWithSelectFetchModeTests { @Test public void testHqlJoinFetchManyToOne(SessionFactoryScope scope) { - SQLStatementInspector sqlStatementInterceptor = (SQLStatementInspector) scope.getStatementInspector(); + SQLStatementInspector sqlStatementInterceptor = scope.getCollectingStatementInspector(); scope.inTransaction( session -> { sqlStatementInterceptor.clear(); @@ -223,7 +219,7 @@ public class EagerToOneWithSelectFetchModeTests { @Test public void testHqlJoinManyToOneAndOneToOne(SessionFactoryScope scope) { - SQLStatementInspector sqlStatementInterceptor = (SQLStatementInspector) scope.getStatementInspector(); + SQLStatementInspector sqlStatementInterceptor = scope.getCollectingStatementInspector(); scope.inTransaction( session -> { sqlStatementInterceptor.clear(); @@ -255,7 +251,7 @@ public class EagerToOneWithSelectFetchModeTests { @Test public void testHqlJoinFetchOneToOne(SessionFactoryScope scope) { - SQLStatementInspector sqlStatementInterceptor = (SQLStatementInspector) scope.getStatementInspector(); + SQLStatementInspector sqlStatementInterceptor = scope.getCollectingStatementInspector(); scope.inTransaction( session -> { sqlStatementInterceptor.clear(); @@ -286,7 +282,7 @@ public class EagerToOneWithSelectFetchModeTests { @Test public void testHqlJoinFetchManyToOneAndOneToOne(SessionFactoryScope scope) { - SQLStatementInspector sqlStatementInterceptor = (SQLStatementInspector) scope.getStatementInspector(); + SQLStatementInspector sqlStatementInterceptor = scope.getCollectingStatementInspector(); scope.inTransaction( session -> { sqlStatementInterceptor.clear(); diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/fetchmode/toone/LazyToOneWithJoinFetchModeTests.java b/hibernate-core/src/test/java/org/hibernate/orm/test/fetchmode/toone/LazyToOneWithJoinFetchModeTests.java index dd735a0399..4cb62e0c60 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/fetchmode/toone/LazyToOneWithJoinFetchModeTests.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/fetchmode/toone/LazyToOneWithJoinFetchModeTests.java @@ -44,7 +44,7 @@ import static org.hamcrest.MatcherAssert.assertThat; LazyToOneWithJoinFetchModeTests.SimpleEntity.class } ) -@SessionFactory(statementInspectorClass = SQLStatementInspector.class) +@SessionFactory(useCollectingStatementInspector = true) @ServiceRegistry( settings = { @Setting(name = AvailableSettings.HBM2DDL_DATABASE_ACTION, value = "create-drop") @@ -69,7 +69,7 @@ public class LazyToOneWithJoinFetchModeTests { @Test public void testFind(SessionFactoryScope scope) { - SQLStatementInspector sqlStatementInterceptor = (SQLStatementInspector) scope.getStatementInspector(); + SQLStatementInspector sqlStatementInterceptor = scope.getCollectingStatementInspector(); scope.inTransaction( session -> { sqlStatementInterceptor.clear(); @@ -92,7 +92,7 @@ public class LazyToOneWithJoinFetchModeTests { @Test public void testHql(SessionFactoryScope scope) { - SQLStatementInspector sqlStatementInterceptor = (SQLStatementInspector) scope.getStatementInspector(); + SQLStatementInspector sqlStatementInterceptor = scope.getCollectingStatementInspector(); scope.inTransaction( session -> { sqlStatementInterceptor.clear(); @@ -124,7 +124,7 @@ public class LazyToOneWithJoinFetchModeTests { @Test public void testHqlJoinManyToOne(SessionFactoryScope scope) { - SQLStatementInspector sqlStatementInterceptor = (SQLStatementInspector) scope.getStatementInspector(); + SQLStatementInspector sqlStatementInterceptor = scope.getCollectingStatementInspector(); scope.inTransaction( session -> { sqlStatementInterceptor.clear(); @@ -158,7 +158,7 @@ public class LazyToOneWithJoinFetchModeTests { @Test public void testHqlJoinOneToOne(SessionFactoryScope scope) { - SQLStatementInspector sqlStatementInterceptor = (SQLStatementInspector) scope.getStatementInspector(); + SQLStatementInspector sqlStatementInterceptor = scope.getCollectingStatementInspector(); scope.inTransaction( session -> { sqlStatementInterceptor.clear(); @@ -192,7 +192,7 @@ public class LazyToOneWithJoinFetchModeTests { @Test public void testHqlJoinFetchManyToOne(SessionFactoryScope scope) { - SQLStatementInspector sqlStatementInterceptor = (SQLStatementInspector) scope.getStatementInspector(); + SQLStatementInspector sqlStatementInterceptor = scope.getCollectingStatementInspector(); scope.inTransaction( session -> { sqlStatementInterceptor.clear(); @@ -224,7 +224,7 @@ public class LazyToOneWithJoinFetchModeTests { @Test public void testHqlJoinManyToOneAndOneToOne(SessionFactoryScope scope) { - SQLStatementInspector sqlStatementInterceptor = (SQLStatementInspector) scope.getStatementInspector(); + SQLStatementInspector sqlStatementInterceptor = scope.getCollectingStatementInspector(); scope.inTransaction( session -> { sqlStatementInterceptor.clear(); @@ -256,7 +256,7 @@ public class LazyToOneWithJoinFetchModeTests { @Test public void testHqlJoinFetchOneToOne(SessionFactoryScope scope) { - SQLStatementInspector sqlStatementInterceptor = (SQLStatementInspector) scope.getStatementInspector(); + SQLStatementInspector sqlStatementInterceptor = scope.getCollectingStatementInspector(); scope.inTransaction( session -> { sqlStatementInterceptor.clear(); @@ -287,7 +287,7 @@ public class LazyToOneWithJoinFetchModeTests { @Test public void testHqlJoinFetchManyToOneAndOneToOne(SessionFactoryScope scope) { - SQLStatementInspector sqlStatementInterceptor = (SQLStatementInspector) scope.getStatementInspector(); + SQLStatementInspector sqlStatementInterceptor = scope.getCollectingStatementInspector(); scope.inTransaction( session -> { sqlStatementInterceptor.clear(); diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/fetchmode/toone/LazyToOneWithSelectFetchModeTests.java b/hibernate-core/src/test/java/org/hibernate/orm/test/fetchmode/toone/LazyToOneWithSelectFetchModeTests.java index bd51f3d519..08c3d70a75 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/fetchmode/toone/LazyToOneWithSelectFetchModeTests.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/fetchmode/toone/LazyToOneWithSelectFetchModeTests.java @@ -17,18 +17,13 @@ import jakarta.persistence.Table; import org.hibernate.Hibernate; import org.hibernate.annotations.Fetch; import org.hibernate.annotations.FetchMode; -import org.hibernate.boot.SessionFactoryBuilder; -import org.hibernate.boot.spi.MetadataImplementor; import org.hibernate.cfg.AvailableSettings; -import org.hibernate.engine.spi.SessionFactoryImplementor; import org.hibernate.sql.ast.SqlAstJoinType; import org.hibernate.testing.jdbc.SQLStatementInspector; -import org.hibernate.testing.jdbc.SQLStatementInterceptor; import org.hibernate.testing.orm.junit.DomainModel; import org.hibernate.testing.orm.junit.ServiceRegistry; import org.hibernate.testing.orm.junit.SessionFactory; -import org.hibernate.testing.orm.junit.SessionFactoryProducer; import org.hibernate.testing.orm.junit.SessionFactoryScope; import org.hibernate.testing.orm.junit.Setting; import org.junit.jupiter.api.AfterEach; @@ -37,7 +32,6 @@ import org.junit.jupiter.api.Test; import static org.hamcrest.CoreMatchers.containsString; import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.CoreMatchers.not; import static org.hamcrest.MatcherAssert.assertThat; import static org.hibernate.testing.hamcrest.CollectionMatchers.hasSize; @@ -50,7 +44,7 @@ import static org.hibernate.testing.hamcrest.CollectionMatchers.hasSize; LazyToOneWithSelectFetchModeTests.SimpleEntity.class } ) -@SessionFactory(statementInspectorClass = SQLStatementInspector.class) +@SessionFactory(useCollectingStatementInspector = true) @ServiceRegistry( settings = { @Setting(name = AvailableSettings.HBM2DDL_DATABASE_ACTION, value = "create-drop") @@ -75,7 +69,7 @@ public class LazyToOneWithSelectFetchModeTests { @Test public void testFind(SessionFactoryScope scope) { - SQLStatementInspector sqlStatementInterceptor = (SQLStatementInspector) scope.getStatementInspector(); + SQLStatementInspector sqlStatementInterceptor = scope.getCollectingStatementInspector(); scope.inTransaction( session -> { sqlStatementInterceptor.clear(); @@ -93,7 +87,7 @@ public class LazyToOneWithSelectFetchModeTests { @Test public void testHql(SessionFactoryScope scope) { - SQLStatementInspector sqlStatementInterceptor = (SQLStatementInspector) scope.getStatementInspector(); + SQLStatementInspector sqlStatementInterceptor = scope.getCollectingStatementInspector(); scope.inTransaction( session -> { sqlStatementInterceptor.clear(); @@ -115,7 +109,7 @@ public class LazyToOneWithSelectFetchModeTests { @Test public void testHqlJoinManyToOne(SessionFactoryScope scope) { - SQLStatementInspector sqlStatementInterceptor = (SQLStatementInspector) scope.getStatementInspector(); + SQLStatementInspector sqlStatementInterceptor = scope.getCollectingStatementInspector(); scope.inTransaction( session -> { sqlStatementInterceptor.clear(); @@ -142,7 +136,7 @@ public class LazyToOneWithSelectFetchModeTests { @Test public void testHqlJoinOneToOne(SessionFactoryScope scope) { - SQLStatementInspector sqlStatementInterceptor = (SQLStatementInspector) scope.getStatementInspector(); + SQLStatementInspector sqlStatementInterceptor = scope.getCollectingStatementInspector(); scope.inTransaction( session -> { sqlStatementInterceptor.clear(); @@ -170,7 +164,7 @@ public class LazyToOneWithSelectFetchModeTests { @Test public void testHqlJoinFetchManyToOne(SessionFactoryScope scope) { - SQLStatementInspector sqlStatementInterceptor = (SQLStatementInspector) scope.getStatementInspector(); + SQLStatementInspector sqlStatementInterceptor = scope.getCollectingStatementInspector(); scope.inTransaction( session -> { sqlStatementInterceptor.clear(); @@ -197,7 +191,7 @@ public class LazyToOneWithSelectFetchModeTests { @Test public void testHqlJoinManyToOneAndOneToOne(SessionFactoryScope scope) { - SQLStatementInspector sqlStatementInterceptor = (SQLStatementInspector) scope.getStatementInspector(); + SQLStatementInspector sqlStatementInterceptor = scope.getCollectingStatementInspector(); scope.inTransaction( session -> { sqlStatementInterceptor.clear(); @@ -224,7 +218,7 @@ public class LazyToOneWithSelectFetchModeTests { @Test public void testHqlJoinFetchOneToOne(SessionFactoryScope scope) { - SQLStatementInspector sqlStatementInterceptor = (SQLStatementInspector) scope.getStatementInspector(); + SQLStatementInspector sqlStatementInterceptor = scope.getCollectingStatementInspector(); scope.inTransaction( session -> { sqlStatementInterceptor.clear(); @@ -251,7 +245,7 @@ public class LazyToOneWithSelectFetchModeTests { @Test public void testHqlJoinFetchManyToOneAndOneToOne(SessionFactoryScope scope) { - SQLStatementInspector sqlStatementInterceptor = (SQLStatementInspector) scope.getStatementInspector(); + SQLStatementInspector sqlStatementInterceptor = scope.getCollectingStatementInspector(); scope.inTransaction( session -> { sqlStatementInterceptor.clear(); diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/graph/HHH15065Test.java b/hibernate-core/src/test/java/org/hibernate/orm/test/graph/HHH15065Test.java index 7fc97338de..036fbdf244 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/graph/HHH15065Test.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/graph/HHH15065Test.java @@ -29,7 +29,7 @@ import jakarta.persistence.ManyToOne; HHH15065Test.Person.class, } ) -@SessionFactory +@SessionFactory(useCollectingStatementInspector = true) class HHH15065Test { @Test @@ -43,7 +43,7 @@ class HHH15065Test { .getResultList(); } ); - SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); + SQLStatementInspector statementInspector = scope.getCollectingStatementInspector(); List sqlQueries = statementInspector.getSqlQueries(); assertEquals( 1, sqlQueries.size() ); assertEquals( "select b1_0.id,a1_0.id,c1_0.id,c2_0.id,e1_0.id" + diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/hql/ManyToOneJoinReuseTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/hql/ManyToOneJoinReuseTest.java index 91b80510d5..bb29c87150 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/hql/ManyToOneJoinReuseTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/hql/ManyToOneJoinReuseTest.java @@ -7,8 +7,6 @@ package org.hibernate.orm.test.hql; -import java.util.Set; - import org.hibernate.query.criteria.HibernateCriteriaBuilder; import org.hibernate.query.criteria.JpaCriteriaQuery; import org.hibernate.query.criteria.JpaRoot; @@ -36,13 +34,13 @@ import jakarta.persistence.criteria.JoinType; ManyToOneJoinReuseTest.BookList.class } ) -@SessionFactory(statementInspectorClass = SQLStatementInspector.class) +@SessionFactory(useCollectingStatementInspector = true) public class ManyToOneJoinReuseTest { @Test @TestForIssue(jiraKey = "HHH-15648") public void fetchAndImplicitPath(SessionFactoryScope scope) { - SQLStatementInspector sqlStatementInterceptor = (SQLStatementInspector) scope.getStatementInspector(); + SQLStatementInspector sqlStatementInterceptor = scope.getCollectingStatementInspector(); sqlStatementInterceptor.clear(); scope.inTransaction( session -> { @@ -62,7 +60,7 @@ public class ManyToOneJoinReuseTest { @Test @TestForIssue(jiraKey = "HHH-15645") public void joinAndImplicitPath(SessionFactoryScope scope) { - SQLStatementInspector sqlStatementInterceptor = (SQLStatementInspector) scope.getStatementInspector(); + SQLStatementInspector sqlStatementInterceptor = scope.getCollectingStatementInspector(); sqlStatementInterceptor.clear(); scope.inTransaction( session -> { diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/hql/NaturalIdDereferenceTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/hql/NaturalIdDereferenceTest.java index 11571788eb..1b8f698a7c 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/hql/NaturalIdDereferenceTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/hql/NaturalIdDereferenceTest.java @@ -46,7 +46,7 @@ import static org.junit.Assert.assertFalse; NaturalIdDereferenceTest.BookRefRef.class } ) -@SessionFactory(statementInspectorClass = SQLStatementInspector.class) +@SessionFactory(useCollectingStatementInspector = true) public class NaturalIdDereferenceTest { @BeforeEach @@ -80,7 +80,7 @@ public class NaturalIdDereferenceTest { @Test public void naturalIdDereferenceTest(SessionFactoryScope scope) { - SQLStatementInspector sqlStatementInterceptor = (SQLStatementInspector) scope.getStatementInspector(); + SQLStatementInspector sqlStatementInterceptor = scope.getCollectingStatementInspector(); sqlStatementInterceptor.clear(); scope.inTransaction( session -> { @@ -95,7 +95,7 @@ public class NaturalIdDereferenceTest { @Test public void normalIdDereferenceFromAlias(SessionFactoryScope scope) { - SQLStatementInspector sqlStatementInterceptor = (SQLStatementInspector) scope.getStatementInspector(); + SQLStatementInspector sqlStatementInterceptor = scope.getCollectingStatementInspector(); sqlStatementInterceptor.clear(); scope.inTransaction( session -> { @@ -110,7 +110,7 @@ public class NaturalIdDereferenceTest { @Test public void naturalIdDereferenceFromAlias(SessionFactoryScope scope) { - SQLStatementInspector sqlStatementInterceptor = (SQLStatementInspector) scope.getStatementInspector(); + SQLStatementInspector sqlStatementInterceptor = scope.getCollectingStatementInspector(); sqlStatementInterceptor.clear(); scope.inTransaction( session -> { @@ -125,7 +125,7 @@ public class NaturalIdDereferenceTest { @Test public void normalIdDereferenceFromImplicitJoin(SessionFactoryScope scope) { - SQLStatementInspector sqlStatementInterceptor = (SQLStatementInspector) scope.getStatementInspector(); + SQLStatementInspector sqlStatementInterceptor = scope.getCollectingStatementInspector(); sqlStatementInterceptor.clear(); scope.inTransaction( session -> { @@ -139,7 +139,7 @@ public class NaturalIdDereferenceTest { @Test public void naturalIdDereferenceFromImplicitJoin(SessionFactoryScope scope) { - SQLStatementInspector sqlStatementInterceptor = (SQLStatementInspector) scope.getStatementInspector(); + SQLStatementInspector sqlStatementInterceptor = scope.getCollectingStatementInspector(); sqlStatementInterceptor.clear(); scope.inTransaction( session -> { @@ -158,7 +158,7 @@ public class NaturalIdDereferenceTest { */ @Test public void nestedNaturalIdDereferenceFromImplicitJoin(SessionFactoryScope scope) { - SQLStatementInspector sqlStatementInterceptor = (SQLStatementInspector) scope.getStatementInspector(); + SQLStatementInspector sqlStatementInterceptor = scope.getCollectingStatementInspector(); sqlStatementInterceptor.clear(); scope.inTransaction( session -> { @@ -176,7 +176,7 @@ public class NaturalIdDereferenceTest { */ @Test public void nestedNaturalIdDereferenceFromImplicitJoin2(SessionFactoryScope scope) { - SQLStatementInspector sqlStatementInterceptor = (SQLStatementInspector) scope.getStatementInspector(); + SQLStatementInspector sqlStatementInterceptor = scope.getCollectingStatementInspector(); sqlStatementInterceptor.clear(); scope.inTransaction( session -> { @@ -190,7 +190,7 @@ public class NaturalIdDereferenceTest { @Test public void doNotDereferenceNaturalIdIfIsReferenceToPrimaryKey(SessionFactoryScope scope) { - SQLStatementInspector sqlStatementInterceptor = (SQLStatementInspector) scope.getStatementInspector(); + SQLStatementInspector sqlStatementInterceptor = scope.getCollectingStatementInspector(); sqlStatementInterceptor.clear(); scope.inTransaction( session -> { @@ -204,7 +204,7 @@ public class NaturalIdDereferenceTest { @Test public void selectedEntityIsNotDereferencedForPrimaryKey(SessionFactoryScope scope) { - SQLStatementInspector sqlStatementInterceptor = (SQLStatementInspector) scope.getStatementInspector(); + SQLStatementInspector sqlStatementInterceptor = scope.getCollectingStatementInspector(); sqlStatementInterceptor.clear(); scope.inTransaction( session -> { @@ -229,7 +229,7 @@ public class NaturalIdDereferenceTest { */ @Test public void selectedEntityIsNotDereferencedForNaturalId(SessionFactoryScope scope) { - SQLStatementInspector sqlStatementInterceptor = (SQLStatementInspector) scope.getStatementInspector(); + SQLStatementInspector sqlStatementInterceptor = scope.getCollectingStatementInspector(); sqlStatementInterceptor.clear(); scope.inTransaction( session -> { @@ -249,7 +249,7 @@ public class NaturalIdDereferenceTest { */ @Test public void dereferenceNaturalIdInJoin(SessionFactoryScope scope) { - SQLStatementInspector sqlStatementInterceptor = (SQLStatementInspector) scope.getStatementInspector(); + SQLStatementInspector sqlStatementInterceptor = scope.getCollectingStatementInspector(); sqlStatementInterceptor.clear(); scope.inTransaction( session -> { @@ -273,7 +273,7 @@ public class NaturalIdDereferenceTest { */ @Test public void dereferenceNaturalIdInJoin2(SessionFactoryScope scope) { - SQLStatementInspector sqlStatementInterceptor = (SQLStatementInspector) scope.getStatementInspector(); + SQLStatementInspector sqlStatementInterceptor = scope.getCollectingStatementInspector(); sqlStatementInterceptor.clear(); scope.inTransaction( session -> { @@ -294,7 +294,7 @@ public class NaturalIdDereferenceTest { */ @Test public void dereferenceNaturalIdInJoin3(SessionFactoryScope scope) { - SQLStatementInspector sqlStatementInterceptor = (SQLStatementInspector) scope.getStatementInspector(); + SQLStatementInspector sqlStatementInterceptor = scope.getCollectingStatementInspector(); sqlStatementInterceptor.clear(); scope.inTransaction( session -> { @@ -316,7 +316,7 @@ public class NaturalIdDereferenceTest { */ @Test public void dereferenceNaturalIdInJoin4(SessionFactoryScope scope) { - SQLStatementInspector sqlStatementInterceptor = (SQLStatementInspector) scope.getStatementInspector(); + SQLStatementInspector sqlStatementInterceptor = scope.getCollectingStatementInspector(); sqlStatementInterceptor.clear(); scope.inTransaction( session -> { diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/id/SequenceGeneratorTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/id/SequenceGeneratorTest.java index 07ddd6b27e..cb38a1376d 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/id/SequenceGeneratorTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/id/SequenceGeneratorTest.java @@ -6,7 +6,6 @@ */ package org.hibernate.orm.test.id; -import org.hibernate.cfg.Environment; import org.hibernate.dialect.SQLServerDialect; import org.hibernate.testing.TestForIssue; @@ -14,10 +13,8 @@ import org.hibernate.testing.jdbc.SQLStatementInspector; import org.hibernate.testing.orm.junit.DialectFeatureChecks; import org.hibernate.testing.orm.junit.DomainModel; import org.hibernate.testing.orm.junit.RequiresDialectFeature; -import org.hibernate.testing.orm.junit.ServiceRegistry; import org.hibernate.testing.orm.junit.SessionFactory; import org.hibernate.testing.orm.junit.SessionFactoryScope; -import org.hibernate.testing.orm.junit.Setting; import org.hibernate.testing.orm.junit.SkipForDialect; import org.junit.jupiter.api.Test; @@ -26,7 +23,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue; @DomainModel( xmlMappings = "org/hibernate/orm/test/id/Person.hbm.xml" ) -@SessionFactory(statementInspectorClass = SQLStatementInspector.class) +@SessionFactory(useCollectingStatementInspector = true) public class SequenceGeneratorTest { @@ -51,7 +48,7 @@ public class SequenceGeneratorTest { ); assertTrue( person.getId() > 0 ); - final SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); + final SQLStatementInspector statementInspector = scope.getCollectingStatementInspector(); assertTrue( statementInspector.getSqlQueries() .stream() .filter( sql -> sql.contains( "product_sequence" ) ) diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/idclass/IdClassTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/idclass/IdClassTest.java index 2187634004..df226c2417 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/idclass/IdClassTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/idclass/IdClassTest.java @@ -29,7 +29,7 @@ import static org.hamcrest.MatcherAssert.assertThat; @DomainModel( annotatedClasses = { IdClassTest.SystemUser.class } ) -@SessionFactory(statementInspectorClass = SQLStatementInspector.class) +@SessionFactory(useCollectingStatementInspector = true) public class IdClassTest { @BeforeEach @@ -55,7 +55,7 @@ public class IdClassTest { @Test public void testGet(SessionFactoryScope scope) { - SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); + SQLStatementInspector statementInspector = scope.getCollectingStatementInspector(); statementInspector.clear(); scope.inTransaction( session -> { @@ -78,7 +78,7 @@ public class IdClassTest { @Test public void testHql(SessionFactoryScope scope) { - SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); + SQLStatementInspector statementInspector = scope.getCollectingStatementInspector(); statementInspector.clear(); scope.inTransaction( session -> { diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/idclass/IdClassWithEagerManyToOneTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/idclass/IdClassWithEagerManyToOneTest.java index f9f620ec3b..e5186085c7 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/idclass/IdClassWithEagerManyToOneTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/idclass/IdClassWithEagerManyToOneTest.java @@ -35,7 +35,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue; IdClassWithEagerManyToOneTest.Subsystem.class } ) -@SessionFactory(statementInspectorClass = SQLStatementInspector.class) +@SessionFactory(useCollectingStatementInspector = true) public class IdClassWithEagerManyToOneTest { @BeforeEach @@ -63,7 +63,7 @@ public class IdClassWithEagerManyToOneTest { @Test public void testGet(SessionFactoryScope scope) { - SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); + SQLStatementInspector statementInspector = scope.getCollectingStatementInspector(); statementInspector.clear(); scope.inTransaction( session -> { @@ -92,7 +92,7 @@ public class IdClassWithEagerManyToOneTest { @Test public void testHql(SessionFactoryScope scope) { - SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); + SQLStatementInspector statementInspector = scope.getCollectingStatementInspector(); statementInspector.clear(); scope.inTransaction( session -> { @@ -166,7 +166,7 @@ public class IdClassWithEagerManyToOneTest { @Test public void testHql2(SessionFactoryScope scope) { - SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); + SQLStatementInspector statementInspector = scope.getCollectingStatementInspector(); statementInspector.clear(); scope.inTransaction( session -> { diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/idclass/IdClassWithLazyManyToOneTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/idclass/IdClassWithLazyManyToOneTest.java index 31ca84066b..a53fd1c509 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/idclass/IdClassWithLazyManyToOneTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/idclass/IdClassWithLazyManyToOneTest.java @@ -37,7 +37,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue; IdClassWithLazyManyToOneTest.Subsystem.class } ) -@SessionFactory(statementInspectorClass = SQLStatementInspector.class) +@SessionFactory(useCollectingStatementInspector = true) public class IdClassWithLazyManyToOneTest { @BeforeEach @@ -65,7 +65,7 @@ public class IdClassWithLazyManyToOneTest { @Test public void testGet(SessionFactoryScope scope) { - SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); + SQLStatementInspector statementInspector = scope.getCollectingStatementInspector(); statementInspector.clear(); scope.inTransaction( session -> { @@ -102,7 +102,7 @@ public class IdClassWithLazyManyToOneTest { @Test public void testHql(SessionFactoryScope scope) { - SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); + SQLStatementInspector statementInspector = scope.getCollectingStatementInspector(); statementInspector.clear(); scope.inTransaction( session -> { @@ -177,7 +177,7 @@ public class IdClassWithLazyManyToOneTest { @Test public void testHql2(SessionFactoryScope scope) { - SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); + SQLStatementInspector statementInspector = scope.getCollectingStatementInspector(); statementInspector.clear(); scope.inTransaction( session -> { diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/association/toone/CriteriaJoinFetchTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/association/toone/CriteriaJoinFetchTest.java index 9a32e8059e..9c02295c78 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/association/toone/CriteriaJoinFetchTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/association/toone/CriteriaJoinFetchTest.java @@ -2,13 +2,9 @@ package org.hibernate.orm.test.jpa.association.toone; import java.util.List; -import org.hibernate.cfg.AvailableSettings; - import org.hibernate.testing.jdbc.SQLStatementInspector; -import org.hibernate.testing.orm.jdbc.DefaultSQLStatementInspectorSettingProvider; import org.hibernate.testing.orm.junit.EntityManagerFactoryScope; import org.hibernate.testing.orm.junit.Jpa; -import org.hibernate.testing.orm.junit.SettingProvider; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -38,13 +34,7 @@ import static org.hamcrest.MatcherAssert.assertThat; CriteriaJoinFetchTest.Address.class, CriteriaJoinFetchTest.Note.class }, - settingProviders = { - @SettingProvider( - settingName = AvailableSettings.STATEMENT_INSPECTOR, - provider = DefaultSQLStatementInspectorSettingProvider.class - ) - } - + useCollectingStatementInspector = true ) public class CriteriaJoinFetchTest { @@ -52,7 +42,7 @@ public class CriteriaJoinFetchTest { @BeforeEach public void setUp(EntityManagerFactoryScope scope) { - statementInspector = scope.getStatementInspector( SQLStatementInspector.class ); + statementInspector = scope.getCollectingStatementInspector(); scope.inTransaction( entityManager -> { diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/ql/MapIssueTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/ql/MapIssueTest.java index 84a8365d7a..e05eb36a2f 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/ql/MapIssueTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/ql/MapIssueTest.java @@ -24,7 +24,7 @@ import org.junit.jupiter.api.Test; annotatedClasses = { MapOwner.class, MapContent.class, Relationship.class }) -@SessionFactory(statementInspectorClass = SQLStatementInspector.class) +@SessionFactory(useCollectingStatementInspector = true) public class MapIssueTest { @Test @@ -39,7 +39,7 @@ public class MapIssueTest { @Test public void testOnlyCollectionTableJoined(SessionFactoryScope scope) { - SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); + SQLStatementInspector statementInspector = scope.getCollectingStatementInspector(); statementInspector.clear(); scope.inTransaction( s -> { @@ -53,7 +53,7 @@ public class MapIssueTest { @Test public void testMapKeyJoinIsOmitted(SessionFactoryScope scope) { - SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); + SQLStatementInspector statementInspector = scope.getCollectingStatementInspector(); statementInspector.clear(); scope.inTransaction( s -> { @@ -67,7 +67,7 @@ public class MapIssueTest { @Test public void testMapKeyJoinIsReused(SessionFactoryScope scope) { - SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); + SQLStatementInspector statementInspector = scope.getCollectingStatementInspector(); statementInspector.clear(); scope.inTransaction( s -> { @@ -81,7 +81,7 @@ public class MapIssueTest { @Test public void testMapKeyJoinIsReusedForFurtherJoin(SessionFactoryScope scope) { - SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); + SQLStatementInspector statementInspector = scope.getCollectingStatementInspector(); statementInspector.clear(); scope.inTransaction( s -> { @@ -95,7 +95,7 @@ public class MapIssueTest { @Test public void testMapKeyJoinIsReusedForFurtherJoinAndElementJoinIsProperlyOrdered(SessionFactoryScope scope) { - SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); + SQLStatementInspector statementInspector = scope.getCollectingStatementInspector(); statementInspector.clear(); scope.inTransaction( s -> { @@ -110,7 +110,7 @@ public class MapIssueTest { @Test @TestForIssue( jiraKey = "HHH-15357") public void testSelectMapKeyFk(SessionFactoryScope scope) { - SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); + SQLStatementInspector statementInspector = scope.getCollectingStatementInspector(); statementInspector.clear(); scope.inTransaction( s -> { diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/query/NamedQueryCommentTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/query/NamedQueryCommentTest.java index a05f743d6e..cc9d821ca1 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/query/NamedQueryCommentTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/query/NamedQueryCommentTest.java @@ -24,12 +24,10 @@ import org.hibernate.dialect.OracleDialect; import org.hibernate.testing.TestForIssue; import org.hibernate.testing.jdbc.SQLStatementInspector; -import org.hibernate.testing.orm.jdbc.DefaultSQLStatementInspectorSettingProvider; import org.hibernate.testing.orm.junit.EntityManagerFactoryScope; import org.hibernate.testing.orm.junit.Jpa; import org.hibernate.testing.orm.junit.RequiresDialect; import org.hibernate.testing.orm.junit.Setting; -import org.hibernate.testing.orm.junit.SettingProvider; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; @@ -45,12 +43,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; integrationSettings = { @Setting( name = AvailableSettings.USE_SQL_COMMENTS, value = "true" ) }, - settingProviders = { - @SettingProvider( - settingName = AvailableSettings.STATEMENT_INSPECTOR, - provider = DefaultSQLStatementInspectorSettingProvider.class - ) - } + useCollectingStatementInspector = true ) @TestForIssue(jiraKey = "HHH-11640") public class NamedQueryCommentTest { @@ -62,7 +55,7 @@ public class NamedQueryCommentTest { @BeforeAll public void setUp(EntityManagerFactoryScope scope) { - statementInspector = scope.getStatementInspector( SQLStatementInspector.class ); + statementInspector = scope.getCollectingStatementInspector(); scope.inTransaction( entityManager -> { diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/fetch/subselect/SimpleEagerSubSelectFetchTests.java b/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/fetch/subselect/SimpleEagerSubSelectFetchTests.java index 4d95c682a0..de75979be7 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/fetch/subselect/SimpleEagerSubSelectFetchTests.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/fetch/subselect/SimpleEagerSubSelectFetchTests.java @@ -38,7 +38,7 @@ import static org.assertj.core.api.Assertions.assertThat; SimpleEagerSubSelectFetchTests.Owner.class, SimpleEagerSubSelectFetchTests.Thing.class }) -@SessionFactory( statementInspectorClass = SQLStatementInspector.class ) +@SessionFactory( useCollectingStatementInspector = true ) public class SimpleEagerSubSelectFetchTests { @Test diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/fetch/subselect/SimpleLazySubSelectFetchTests.java b/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/fetch/subselect/SimpleLazySubSelectFetchTests.java index 90781e0ad6..a67328a93c 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/fetch/subselect/SimpleLazySubSelectFetchTests.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/fetch/subselect/SimpleLazySubSelectFetchTests.java @@ -38,12 +38,12 @@ import static org.assertj.core.api.Assertions.assertThat; SimpleLazySubSelectFetchTests.Owner.class, SimpleLazySubSelectFetchTests.Thing.class }) -@SessionFactory( statementInspectorClass = SQLStatementInspector.class ) +@SessionFactory( useCollectingStatementInspector = true ) public class SimpleLazySubSelectFetchTests { @Test public void smokeTest(SessionFactoryScope scope) { - final SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); + final SQLStatementInspector statementInspector = scope.getCollectingStatementInspector(); statementInspector.clear(); scope.inTransaction( (session) -> { @@ -93,7 +93,7 @@ public class SimpleLazySubSelectFetchTests { @Test public void baselineJoinFetchTest(SessionFactoryScope scope) { - final SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); + final SQLStatementInspector statementInspector = scope.getCollectingStatementInspector(); statementInspector.clear(); scope.inTransaction( (session) -> { diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/fetch/subselect/SimpleMultipleEagerSubSelectFetchTests.java b/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/fetch/subselect/SimpleMultipleEagerSubSelectFetchTests.java index 27b980dd3a..6a70a880dc 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/fetch/subselect/SimpleMultipleEagerSubSelectFetchTests.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/fetch/subselect/SimpleMultipleEagerSubSelectFetchTests.java @@ -44,7 +44,7 @@ import static org.assertj.core.api.Assertions.assertThat; SimpleMultipleEagerSubSelectFetchTests.Thing.class, SimpleMultipleEagerSubSelectFetchTests.Trinket.class, }) -@SessionFactory( statementInspectorClass = SQLStatementInspector.class ) +@SessionFactory( useCollectingStatementInspector = true ) public class SimpleMultipleEagerSubSelectFetchTests { @Test diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/fetch/subselect/SimpleMultipleLazySubSelectFetchTests.java b/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/fetch/subselect/SimpleMultipleLazySubSelectFetchTests.java index 2742978440..3e133b89a1 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/fetch/subselect/SimpleMultipleLazySubSelectFetchTests.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/fetch/subselect/SimpleMultipleLazySubSelectFetchTests.java @@ -44,12 +44,12 @@ import static org.assertj.core.api.Assertions.assertThat; SimpleMultipleLazySubSelectFetchTests.Thing.class, SimpleMultipleLazySubSelectFetchTests.Trinket.class, }) -@SessionFactory( statementInspectorClass = SQLStatementInspector.class ) +@SessionFactory( useCollectingStatementInspector = true ) public class SimpleMultipleLazySubSelectFetchTests { @Test public void smokeTest(SessionFactoryScope scope) { - final SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); + final SQLStatementInspector statementInspector = scope.getCollectingStatementInspector(); statementInspector.clear(); scope.inTransaction( (session) -> { diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/fetch/subselect/SubselectFetchCollectionFromBatchTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/fetch/subselect/SubselectFetchCollectionFromBatchTest.java index f318fd5d91..56a8f56e1c 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/fetch/subselect/SubselectFetchCollectionFromBatchTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/fetch/subselect/SubselectFetchCollectionFromBatchTest.java @@ -94,7 +94,7 @@ public class SubselectFetchCollectionFromBatchTest { return new EmployeeGroup[] { group1, group2 }; }); - final SQLStatementInspector statementInspector = scope.getStatementInspector( SQLStatementInspector.class ); + final SQLStatementInspector statementInspector = scope.getCollectingStatementInspector(); statementInspector.clear(); scope.inTransaction( (s) -> { diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/fetch/subselect/SubselectFetchTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/fetch/subselect/SubselectFetchTest.java index 4fd23f13bf..7ee1acf4f4 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/fetch/subselect/SubselectFetchTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/fetch/subselect/SubselectFetchTest.java @@ -28,9 +28,9 @@ import jakarta.persistence.criteria.JoinType; import jakarta.persistence.criteria.Root; import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * @author Gavin King @@ -305,7 +305,7 @@ public class SubselectFetchTest { @Test public void testSubselectFetchCriteria(SessionFactoryScope scope) { - final SQLStatementInspector statementInspector = scope.getStatementInspector( SQLStatementInspector.class ); + final SQLStatementInspector statementInspector = scope.getCollectingStatementInspector(); statementInspector.clear(); scope.inTransaction( diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/inheritance/discriminator/MultiInheritanceImplicitDowncastTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/inheritance/discriminator/MultiInheritanceImplicitDowncastTest.java index ed850c50b5..aef0b5fca4 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/inheritance/discriminator/MultiInheritanceImplicitDowncastTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/inheritance/discriminator/MultiInheritanceImplicitDowncastTest.java @@ -80,7 +80,7 @@ import jakarta.persistence.OrderColumn; MultiInheritanceImplicitDowncastTest.PolymorphicSub1.class, MultiInheritanceImplicitDowncastTest.PolymorphicSub2.class }) -@SessionFactory(statementInspectorClass = SQLStatementInspector.class) +@SessionFactory(useCollectingStatementInspector = true) public class MultiInheritanceImplicitDowncastTest { @Test @@ -117,7 +117,7 @@ public class MultiInheritanceImplicitDowncastTest { } private void testMultiJoinAddition(SessionFactoryScope scope, String joinColumnBase, String hql) { - SQLStatementInspector sqlStatementInterceptor = (SQLStatementInspector) scope.getStatementInspector(); + SQLStatementInspector sqlStatementInterceptor = scope.getCollectingStatementInspector(); scope.inTransaction( s -> { sqlStatementInterceptor.clear(); diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/manytoone/ManyToOneBidirectionalCircularityTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/manytoone/ManyToOneBidirectionalCircularityTest.java index 00e777d01c..b9e92ad99d 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/manytoone/ManyToOneBidirectionalCircularityTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/manytoone/ManyToOneBidirectionalCircularityTest.java @@ -31,7 +31,7 @@ import static org.hibernate.orm.test.mapping.manytoone.ManyToOneBidirectionalCir EntityTest2.class } ) -@SessionFactory(statementInspectorClass = SQLStatementInspector.class) +@SessionFactory(useCollectingStatementInspector = true) public class ManyToOneBidirectionalCircularityTest { @BeforeEach @@ -50,7 +50,7 @@ public class ManyToOneBidirectionalCircularityTest { @Test public void testGet(SessionFactoryScope scope) { - SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); + SQLStatementInspector statementInspector = scope.getCollectingStatementInspector(); statementInspector.clear(); scope.inTransaction( session -> { diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/manytoone/ManyToOneBidirectionalTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/manytoone/ManyToOneBidirectionalTest.java index 68a3796ead..fc8d8952ce 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/manytoone/ManyToOneBidirectionalTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/manytoone/ManyToOneBidirectionalTest.java @@ -25,7 +25,7 @@ import static org.hibernate.orm.test.mapping.manytoone.ManyToOneBidirectionalTes * @author Andrea Boriero */ @DomainModel( annotatedClasses = { EntityTest.class, EntityTest2.class } ) -@SessionFactory(statementInspectorClass = SQLStatementInspector.class) +@SessionFactory(useCollectingStatementInspector = true) public class ManyToOneBidirectionalTest { @BeforeEach @@ -46,7 +46,7 @@ public class ManyToOneBidirectionalTest { @Test public void testGet(SessionFactoryScope scope) { - SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); + SQLStatementInspector statementInspector = scope.getCollectingStatementInspector(); statementInspector.clear(); scope.inTransaction( session -> { diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/onetomany/OneToManyBidirectionalTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/onetomany/OneToManyBidirectionalTest.java index 1180d91546..cb9b93acbe 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/onetomany/OneToManyBidirectionalTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/onetomany/OneToManyBidirectionalTest.java @@ -22,7 +22,6 @@ import org.hibernate.stat.Statistics; import org.hibernate.testing.jdbc.SQLStatementInspector; import org.hibernate.testing.orm.junit.DomainModel; -import org.hibernate.testing.orm.junit.FailureExpected; import org.hibernate.testing.orm.junit.ServiceRegistry; import org.hibernate.testing.orm.junit.SessionFactory; import org.hibernate.testing.orm.junit.SessionFactoryScope; @@ -48,7 +47,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue; OneToManyBidirectionalTest.Item.class } ) -@SessionFactory(statementInspectorClass = SQLStatementInspector.class) +@SessionFactory(useCollectingStatementInspector = true) @ServiceRegistry( settings = { @Setting(name = AvailableSettings.GENERATE_STATISTICS, value = "true"), @@ -84,7 +83,7 @@ public class OneToManyBidirectionalTest { @Test public void testFetchingSameAssociationTwice(SessionFactoryScope scope) { - SQLStatementInspector sqlStatementInterceptor = (SQLStatementInspector) scope.getStatementInspector(); + SQLStatementInspector sqlStatementInterceptor = scope.getCollectingStatementInspector(); scope.inTransaction( session -> { Statistics statistics = session.getSessionFactory().getStatistics(); @@ -135,7 +134,7 @@ public class OneToManyBidirectionalTest { @Test public void testRetrievingItem(SessionFactoryScope scope) { - SQLStatementInspector sqlStatementInterceptor = (SQLStatementInspector) scope.getStatementInspector(); + SQLStatementInspector sqlStatementInterceptor = scope.getCollectingStatementInspector(); scope.inTransaction( session -> { Statistics statistics = session.getSessionFactory().getStatistics(); @@ -356,7 +355,7 @@ public class OneToManyBidirectionalTest { @Test public void testRetrievingOrder(SessionFactoryScope scope) { - SQLStatementInspector sqlStatementInterceptor = (SQLStatementInspector) scope.getStatementInspector(); + SQLStatementInspector sqlStatementInterceptor = scope.getCollectingStatementInspector(); scope.inTransaction( session -> { Statistics statistics = session.getSessionFactory().getStatistics(); statistics.clear(); @@ -591,7 +590,7 @@ public class OneToManyBidirectionalTest { @Test public void testItemFetchJoin(SessionFactoryScope scope) { - SQLStatementInspector sqlStatementInterceptor = (SQLStatementInspector) scope.getStatementInspector(); + SQLStatementInspector sqlStatementInterceptor = scope.getCollectingStatementInspector(); scope.inTransaction( session -> { Statistics statistics = session.getSessionFactory().getStatistics(); statistics.clear(); @@ -624,7 +623,7 @@ public class OneToManyBidirectionalTest { @Test public void testItemJoinWithFetchJoin(SessionFactoryScope scope) { - SQLStatementInspector sqlStatementInterceptor = (SQLStatementInspector) scope.getStatementInspector(); + SQLStatementInspector sqlStatementInterceptor = scope.getCollectingStatementInspector(); Assertions.assertThrows( IllegalArgumentException.class, () -> scope.inTransaction( session -> { Statistics statistics = session.getSessionFactory().getStatistics(); diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/onetomany/OneToManyTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/onetomany/OneToManyTest.java index a34d003280..6de0068e3d 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/onetomany/OneToManyTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/onetomany/OneToManyTest.java @@ -43,7 +43,7 @@ import static org.junit.jupiter.api.Assertions.fail; Key.class } ) -@SessionFactory(statementInspectorClass = SQLStatementInspector.class) +@SessionFactory(useCollectingStatementInspector = true) public class OneToManyTest { public static final String CARD_ID = "cardId"; public static final String CARD_FIELD_ID = "cardFieldId"; @@ -81,7 +81,7 @@ public class OneToManyTest { @Test public void testGet(SessionFactoryScope scope) { - SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); + SQLStatementInspector statementInspector = scope.getCollectingStatementInspector(); statementInspector.clear(); scope.inTransaction( session -> { diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/onetoone/OneToOneMapsIdJoinColumnTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/onetoone/OneToOneMapsIdJoinColumnTest.java index ea8cc20ba0..2e25905e79 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/onetoone/OneToOneMapsIdJoinColumnTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/onetoone/OneToOneMapsIdJoinColumnTest.java @@ -13,13 +13,9 @@ import jakarta.persistence.JoinColumn; import jakarta.persistence.MapsId; import jakarta.persistence.OneToOne; -import org.hibernate.cfg.AvailableSettings; - -import org.hibernate.testing.orm.jdbc.DefaultSQLStatementInspectorSettingProvider; import org.hibernate.testing.jdbc.SQLStatementInspector; import org.hibernate.testing.orm.junit.EntityManagerFactoryScope; import org.hibernate.testing.orm.junit.Jpa; -import org.hibernate.testing.orm.junit.SettingProvider; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -33,12 +29,7 @@ import static org.junit.jupiter.api.Assertions.assertSame; OneToOneMapsIdJoinColumnTest.Person.class, OneToOneMapsIdJoinColumnTest.PersonDetails.class }, - settingProviders = { - @SettingProvider( - settingName = AvailableSettings.STATEMENT_INSPECTOR, - provider = DefaultSQLStatementInspectorSettingProvider.class - ) - } + useCollectingStatementInspector = true ) public class OneToOneMapsIdJoinColumnTest { @@ -59,7 +50,7 @@ public class OneToOneMapsIdJoinColumnTest { @Test public void testLifecycle(EntityManagerFactoryScope scope) { - SQLStatementInspector statementInspector = scope.getStatementInspector( SQLStatementInspector.class ); + SQLStatementInspector statementInspector = scope.getCollectingStatementInspector(); statementInspector.clear(); scope.inTransaction( entityManager -> { diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/onetoone/ToOneSelfReferenceTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/onetoone/ToOneSelfReferenceTest.java index 998d4c77ed..bfd88ce06f 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/onetoone/ToOneSelfReferenceTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/onetoone/ToOneSelfReferenceTest.java @@ -26,7 +26,7 @@ import static org.hibernate.orm.test.mapping.onetoone.ToOneSelfReferenceTest.Ent * @author Andrea Boriero */ @DomainModel( annotatedClasses = { EntityTest.class } ) -@SessionFactory(statementInspectorClass = SQLStatementInspector.class) +@SessionFactory(useCollectingStatementInspector = true) public class ToOneSelfReferenceTest { @BeforeEach @@ -48,7 +48,7 @@ public class ToOneSelfReferenceTest { @Test public void testGet(SessionFactoryScope scope) { - SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); + SQLStatementInspector statementInspector = scope.getCollectingStatementInspector(); statementInspector.clear(); scope.inTransaction( session -> { diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/notfound/HqlExplicitLeftJoinTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/notfound/HqlExplicitLeftJoinTest.java index 1f70ed161c..78dd690bf4 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/notfound/HqlExplicitLeftJoinTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/notfound/HqlExplicitLeftJoinTest.java @@ -20,14 +20,14 @@ import jakarta.persistence.ManyToOne; annotatedClasses = { HqlExplicitLeftJoinTest.EntityA.class, HqlExplicitLeftJoinTest.EntityB.class } ) @SessionFactory( - statementInspectorClass = SQLStatementInspector.class + useCollectingStatementInspector = true ) @TestForIssue( jiraKey = "HHH-15342") public class HqlExplicitLeftJoinTest { @Test public void testExplicitLeftJoin(SessionFactoryScope scope) { - final SQLStatementInspector sqlStatementInterceptor = (SQLStatementInspector) scope.getStatementInspector(); + final SQLStatementInspector sqlStatementInterceptor = scope.getCollectingStatementInspector(); sqlStatementInterceptor.clear(); scope.inTransaction( session -> { @@ -46,7 +46,7 @@ public class HqlExplicitLeftJoinTest { @Test public void testExplicitLeftJoin2(SessionFactoryScope scope) { - final SQLStatementInspector sqlStatementInterceptor = (SQLStatementInspector) scope.getStatementInspector(); + final SQLStatementInspector sqlStatementInterceptor = scope.getCollectingStatementInspector(); sqlStatementInterceptor.clear(); scope.inTransaction( session -> { @@ -65,7 +65,7 @@ public class HqlExplicitLeftJoinTest { @Test public void testImplicitJoin(SessionFactoryScope scope) { - final SQLStatementInspector sqlStatementInterceptor = (SQLStatementInspector) scope.getStatementInspector(); + final SQLStatementInspector sqlStatementInterceptor = scope.getCollectingStatementInspector(); sqlStatementInterceptor.clear(); scope.inTransaction( session -> { @@ -85,7 +85,7 @@ public class HqlExplicitLeftJoinTest { @Test public void testImplicitJoin2(SessionFactoryScope scope) { - final SQLStatementInspector sqlStatementInterceptor = (SQLStatementInspector) scope.getStatementInspector(); + final SQLStatementInspector sqlStatementInterceptor = scope.getCollectingStatementInspector(); sqlStatementInterceptor.clear(); scope.inTransaction( session -> { @@ -104,7 +104,7 @@ public class HqlExplicitLeftJoinTest { @Test public void testImplicitJoinWithNoExplicitJoins(SessionFactoryScope scope) { - final SQLStatementInspector sqlStatementInterceptor = (SQLStatementInspector) scope.getStatementInspector(); + final SQLStatementInspector sqlStatementInterceptor = scope.getCollectingStatementInspector(); sqlStatementInterceptor.clear(); scope.inTransaction( session -> { diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/query/CompareEntityValuedPathsTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/query/CompareEntityValuedPathsTest.java index 34370d9c71..c543fcc953 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/query/CompareEntityValuedPathsTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/query/CompareEntityValuedPathsTest.java @@ -24,13 +24,13 @@ import static org.junit.jupiter.api.Assertions.assertEquals; @DomainModel( annotatedClasses = { CompareEntityValuedPathsTest.Person.class } ) -@SessionFactory(statementInspectorClass = SQLStatementInspector.class) +@SessionFactory(useCollectingStatementInspector = true) @TestForIssue(jiraKey = "HHH-15349") public class CompareEntityValuedPathsTest { @Test public void testCompareOneToManyUK(SessionFactoryScope scope) { - final SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); + final SQLStatementInspector statementInspector = scope.getCollectingStatementInspector(); scope.inTransaction( session -> { statementInspector.clear(); @@ -54,7 +54,7 @@ public class CompareEntityValuedPathsTest { @Test public void testCompareOneToManyPK(SessionFactoryScope scope) { - final SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); + final SQLStatementInspector statementInspector = scope.getCollectingStatementInspector(); scope.inTransaction( session -> { statementInspector.clear(); @@ -78,7 +78,7 @@ public class CompareEntityValuedPathsTest { @Test public void testManyToOneIsNull(SessionFactoryScope scope) { - final SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); + final SQLStatementInspector statementInspector = scope.getCollectingStatementInspector(); scope.inTransaction( session -> { statementInspector.clear(); @@ -98,7 +98,7 @@ public class CompareEntityValuedPathsTest { @Test public void testComparePKWithOneToManyUK(SessionFactoryScope scope) { - final SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); + final SQLStatementInspector statementInspector = scope.getCollectingStatementInspector(); scope.inTransaction( session -> { statementInspector.clear(); @@ -123,7 +123,7 @@ public class CompareEntityValuedPathsTest { @Test public void testCompareUKWithOneToManyPK(SessionFactoryScope scope) { - final SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); + final SQLStatementInspector statementInspector = scope.getCollectingStatementInspector(); scope.inTransaction( session -> { statementInspector.clear(); @@ -148,7 +148,7 @@ public class CompareEntityValuedPathsTest { @Test public void testComparePKWithMappedByOneToManyPK(SessionFactoryScope scope) { - final SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); + final SQLStatementInspector statementInspector = scope.getCollectingStatementInspector(); scope.inTransaction( session -> { statementInspector.clear(); @@ -172,7 +172,7 @@ public class CompareEntityValuedPathsTest { @Test public void testComparePKWithMappedByOneToManyUK(SessionFactoryScope scope) { - final SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); + final SQLStatementInspector statementInspector = scope.getCollectingStatementInspector(); scope.inTransaction( session -> { statementInspector.clear(); @@ -196,7 +196,7 @@ public class CompareEntityValuedPathsTest { @Test public void testOneToManyUKIsNotNull(SessionFactoryScope scope) { - final SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); + final SQLStatementInspector statementInspector = scope.getCollectingStatementInspector(); scope.inTransaction( session -> { statementInspector.clear(); @@ -217,7 +217,7 @@ public class CompareEntityValuedPathsTest { @Test public void testOneToManyPKIsNotNull(SessionFactoryScope scope) { - final SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); + final SQLStatementInspector statementInspector = scope.getCollectingStatementInspector(); scope.inTransaction( session -> { statementInspector.clear(); @@ -238,7 +238,7 @@ public class CompareEntityValuedPathsTest { @Test public void testCompareOneToManyUKWithOneToManyPK(SessionFactoryScope scope) { - final SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); + final SQLStatementInspector statementInspector = scope.getCollectingStatementInspector(); scope.inTransaction( session -> { statementInspector.clear(); @@ -260,7 +260,7 @@ public class CompareEntityValuedPathsTest { @Test public void testCompareOneToManyPKWithOneToManyUK(SessionFactoryScope scope) { - final SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); + final SQLStatementInspector statementInspector = scope.getCollectingStatementInspector(); scope.inTransaction( session -> { statementInspector.clear(); @@ -282,7 +282,7 @@ public class CompareEntityValuedPathsTest { @Test public void testCompareOneToManyUKWithSubqueryOneToManyPK(SessionFactoryScope scope) { - final SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); + final SQLStatementInspector statementInspector = scope.getCollectingStatementInspector(); scope.inTransaction( session -> { statementInspector.clear(); @@ -303,7 +303,7 @@ public class CompareEntityValuedPathsTest { @Test public void testCompareOneToManyPKWithSubqueryOneToManyUK(SessionFactoryScope scope) { - final SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); + final SQLStatementInspector statementInspector = scope.getCollectingStatementInspector(); scope.inTransaction( session -> { statementInspector.clear(); @@ -324,7 +324,7 @@ public class CompareEntityValuedPathsTest { @Test public void testCompareManyToOneUK(SessionFactoryScope scope) { - final SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); + final SQLStatementInspector statementInspector = scope.getCollectingStatementInspector(); scope.inTransaction( session -> { statementInspector.clear(); @@ -347,7 +347,7 @@ public class CompareEntityValuedPathsTest { @Test public void testCompareManyToOnePK(SessionFactoryScope scope) { - final SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); + final SQLStatementInspector statementInspector = scope.getCollectingStatementInspector(); scope.inTransaction( session -> { statementInspector.clear(); diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/query/InClauseParameterPaddingCriteriaTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/query/InClauseParameterPaddingCriteriaTest.java index 2cb9a7385a..4ae4a4a075 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/query/InClauseParameterPaddingCriteriaTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/query/InClauseParameterPaddingCriteriaTest.java @@ -13,11 +13,9 @@ import org.hibernate.cfg.AvailableSettings; import org.hibernate.testing.TestForIssue; import org.hibernate.testing.jdbc.SQLStatementInspector; -import org.hibernate.testing.orm.jdbc.DefaultSQLStatementInspectorSettingProvider; import org.hibernate.testing.orm.junit.EntityManagerFactoryScope; import org.hibernate.testing.orm.junit.Jpa; import org.hibernate.testing.orm.junit.Setting; -import org.hibernate.testing.orm.junit.SettingProvider; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; @@ -42,12 +40,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue; @Setting(name = AvailableSettings.USE_SQL_COMMENTS, value = "true"), @Setting(name = AvailableSettings.IN_CLAUSE_PARAMETER_PADDING, value = "true"), }, - settingProviders = { - @SettingProvider( - settingName = AvailableSettings.STATEMENT_INSPECTOR, - provider = DefaultSQLStatementInspectorSettingProvider.class - ) - } + useCollectingStatementInspector = true ) public class InClauseParameterPaddingCriteriaTest { @@ -62,7 +55,7 @@ public class InClauseParameterPaddingCriteriaTest { @Test public void testInClauseParameterPadding(EntityManagerFactoryScope scope) { - final SQLStatementInspector statementInspector = scope.getStatementInspector( SQLStatementInspector.class ); + final SQLStatementInspector statementInspector = scope.getCollectingStatementInspector(); statementInspector.clear(); scope.inTransaction( entityManager -> { @@ -86,7 +79,7 @@ public class InClauseParameterPaddingCriteriaTest { @Test public void testInClauseParameterPaddingForExpressions(EntityManagerFactoryScope scope) { - final SQLStatementInspector statementInspector = scope.getStatementInspector( SQLStatementInspector.class ); + final SQLStatementInspector statementInspector = scope.getCollectingStatementInspector(); statementInspector.clear(); scope.inTransaction( entityManager -> { diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/query/InClauseParameterPaddingTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/query/InClauseParameterPaddingTest.java index 070d3eafbe..5ba5f6eb61 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/query/InClauseParameterPaddingTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/query/InClauseParameterPaddingTest.java @@ -12,11 +12,9 @@ import org.hibernate.cfg.AvailableSettings; import org.hibernate.testing.TestForIssue; import org.hibernate.testing.jdbc.SQLStatementInspector; -import org.hibernate.testing.orm.jdbc.DefaultSQLStatementInspectorSettingProvider; import org.hibernate.testing.orm.junit.EntityManagerFactoryScope; import org.hibernate.testing.orm.junit.Jpa; import org.hibernate.testing.orm.junit.Setting; -import org.hibernate.testing.orm.junit.SettingProvider; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -36,12 +34,7 @@ import static org.junit.Assert.assertTrue; @Setting(name = AvailableSettings.USE_SQL_COMMENTS, value = "true"), @Setting(name = AvailableSettings.IN_CLAUSE_PARAMETER_PADDING, value = "true") }, - settingProviders = { - @SettingProvider( - settingName = AvailableSettings.STATEMENT_INSPECTOR, - provider = DefaultSQLStatementInspectorSettingProvider.class - ) - } + useCollectingStatementInspector = true ) public class InClauseParameterPaddingTest { @@ -76,7 +69,7 @@ public class InClauseParameterPaddingTest { EntityManagerFactoryScope scope, String expectedInClause, Integer... ids) { - final SQLStatementInspector sqlStatementInterceptor = scope.getStatementInspector( SQLStatementInspector.class ); + final SQLStatementInspector sqlStatementInterceptor = scope.getCollectingStatementInspector(); sqlStatementInterceptor.clear(); scope.inTransaction( entityManager -> { diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/query/MaxInExpressionParameterPaddingTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/query/MaxInExpressionParameterPaddingTest.java index 59d1df1cb5..249656c3cb 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/query/MaxInExpressionParameterPaddingTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/query/MaxInExpressionParameterPaddingTest.java @@ -14,7 +14,6 @@ import org.hibernate.dialect.H2Dialect; import org.hibernate.testing.TestForIssue; import org.hibernate.testing.jdbc.SQLStatementInspector; -import org.hibernate.testing.orm.jdbc.DefaultSQLStatementInspectorSettingProvider; import org.hibernate.testing.orm.junit.EntityManagerFactoryScope; import org.hibernate.testing.orm.junit.Jpa; import org.hibernate.testing.orm.junit.RequiresDialect; @@ -43,12 +42,9 @@ import static org.junit.jupiter.api.Assertions.assertTrue; @SettingProvider( settingName = AvailableSettings.DIALECT, provider = MaxInExpressionParameterPaddingTest.DialectProvider.class - ), - @SettingProvider( - settingName = AvailableSettings.STATEMENT_INSPECTOR, - provider = DefaultSQLStatementInspectorSettingProvider.class ) - } + }, + useCollectingStatementInspector = true ) public class MaxInExpressionParameterPaddingTest { @@ -76,7 +72,7 @@ public class MaxInExpressionParameterPaddingTest { @Test public void testInClauseParameterPadding(EntityManagerFactoryScope scope) { - final SQLStatementInspector statementInspector = scope.getStatementInspector( SQLStatementInspector.class ); + final SQLStatementInspector statementInspector = scope.getCollectingStatementInspector(); statementInspector.clear(); scope.inTransaction( entityManager -> @@ -98,7 +94,7 @@ public class MaxInExpressionParameterPaddingTest { @TestForIssue(jiraKey = "HHH-14109") @Test public void testInClauseParameterPaddingToLimit(EntityManagerFactoryScope scope) { - final SQLStatementInspector statementInspector = scope.getStatementInspector( SQLStatementInspector.class ); + final SQLStatementInspector statementInspector = scope.getCollectingStatementInspector(); statementInspector.clear(); scope.inTransaction( @@ -123,7 +119,7 @@ public class MaxInExpressionParameterPaddingTest { @Test public void testInClauseParameterSplittingAfterLimit(EntityManagerFactoryScope scope) { - final SQLStatementInspector statementInspector = scope.getStatementInspector( SQLStatementInspector.class ); + final SQLStatementInspector statementInspector = scope.getCollectingStatementInspector(); statementInspector.clear(); scope.inTransaction( @@ -149,7 +145,7 @@ public class MaxInExpressionParameterPaddingTest { @Test public void testInClauseParameterSplittingAfterLimit2(EntityManagerFactoryScope scope) { - final SQLStatementInspector statementInspector = scope.getStatementInspector( SQLStatementInspector.class ); + final SQLStatementInspector statementInspector = scope.getCollectingStatementInspector(); statementInspector.clear(); scope.inTransaction( @@ -175,7 +171,7 @@ public class MaxInExpressionParameterPaddingTest { @Test public void testInClauseParameterSplittingAfterLimit3(EntityManagerFactoryScope scope) { - final SQLStatementInspector statementInspector = scope.getStatementInspector( SQLStatementInspector.class ); + final SQLStatementInspector statementInspector = scope.getCollectingStatementInspector(); statementInspector.clear(); scope.inTransaction( diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/query/hql/GroupByTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/query/hql/GroupByTest.java index 599a3ac32f..8cd14f93e4 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/query/hql/GroupByTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/query/hql/GroupByTest.java @@ -30,7 +30,7 @@ import static org.assertj.core.api.Assertions.assertThat; */ @ServiceRegistry @DomainModel(standardModels = StandardDomainModel.CONTACTS) -@SessionFactory( statementInspectorClass = SQLStatementInspector.class ) +@SessionFactory( useCollectingStatementInspector = true ) public class GroupByTest { @Test @@ -46,7 +46,7 @@ public class GroupByTest { @Test @TestForIssue( jiraKey = "HHH-9301" ) public void testGroupByAliasedBasicPart(SessionFactoryScope scope) { - final SQLStatementInspector sqlStatementInspector = (SQLStatementInspector) scope.getStatementInspector(); + final SQLStatementInspector sqlStatementInspector = scope.getCollectingStatementInspector(); sqlStatementInspector.clear(); scope.inSession( (session) -> { @@ -67,7 +67,7 @@ public class GroupByTest { @Test @TestForIssue( jiraKey = "HHH-9301" ) public void testGroupByAliasedCompositePart(SessionFactoryScope scope) { - final SQLStatementInspector sqlStatementInspector = (SQLStatementInspector) scope.getStatementInspector(); + final SQLStatementInspector sqlStatementInspector = scope.getCollectingStatementInspector(); sqlStatementInspector.clear(); scope.inTransaction( (session) -> { @@ -92,7 +92,7 @@ public class GroupByTest { @Test @TestForIssue( jiraKey = "HHH-9301" ) public void testGroupByMultipleAliases(SessionFactoryScope scope) { - final SQLStatementInspector sqlStatementInspector = (SQLStatementInspector) scope.getStatementInspector(); + final SQLStatementInspector sqlStatementInspector = scope.getCollectingStatementInspector(); sqlStatementInspector.clear(); scope.inTransaction( (session) -> { diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/query/hql/InsertSelectTests.java b/hibernate-core/src/test/java/org/hibernate/orm/test/query/hql/InsertSelectTests.java index 0fe86db503..0911db975a 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/query/hql/InsertSelectTests.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/query/hql/InsertSelectTests.java @@ -30,7 +30,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; InsertSelectTests.EntityEntry.class, InsertSelectTests.EntitySource.class }) -@SessionFactory(statementInspectorClass = SQLStatementInspector.class) +@SessionFactory(useCollectingStatementInspector = true) public class InsertSelectTests { @BeforeEach @@ -55,7 +55,7 @@ public class InsertSelectTests { @Test @TestForIssue( jiraKey = "HHH-15527") public void testInsertSelectGeneratedAssigned(SessionFactoryScope scope) { - final SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); + final SQLStatementInspector statementInspector = scope.getCollectingStatementInspector(); scope.inTransaction( session -> { statementInspector.clear(); diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/query/hql/JoinOrderTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/query/hql/JoinOrderTest.java index 7776bc2230..01d5505728 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/query/hql/JoinOrderTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/query/hql/JoinOrderTest.java @@ -25,13 +25,13 @@ import static org.assertj.core.api.Assertions.assertThat; */ @TestForIssue( jiraKey = "HHH-14201" ) @DomainModel( annotatedClasses = { JoinOrderTest.EntityA.class, JoinOrderTest.EntityB.class, JoinOrderTest.EntityC.class } ) -@SessionFactory( statementInspectorClass = SQLStatementInspector.class ) +@SessionFactory( useCollectingStatementInspector = true ) public class JoinOrderTest { @Test public void testJoinOrder(SessionFactoryScope scope) { scope.inTransaction( (session) -> { - final SQLStatementInspector sqlStatementInspector = (SQLStatementInspector) scope.getStatementInspector(); + final SQLStatementInspector sqlStatementInspector = scope.getCollectingStatementInspector(); sqlStatementInspector.clear(); final String hql = "select 1" diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/query/hql/size/OneToManySizeTest2.java b/hibernate-core/src/test/java/org/hibernate/orm/test/query/hql/size/OneToManySizeTest2.java index 613a6124e2..12c24486fa 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/query/hql/size/OneToManySizeTest2.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/query/hql/size/OneToManySizeTest2.java @@ -10,15 +10,12 @@ import java.util.List; import java.util.Locale; import org.hibernate.Hibernate; -import org.hibernate.cfg.AvailableSettings; import org.hibernate.testing.TestForIssue; import org.hibernate.testing.jdbc.SQLStatementInspector; import org.hibernate.testing.orm.junit.DomainModel; -import org.hibernate.testing.orm.junit.ServiceRegistry; import org.hibernate.testing.orm.junit.SessionFactory; import org.hibernate.testing.orm.junit.SessionFactoryScope; -import org.hibernate.testing.orm.junit.Setting; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -30,13 +27,10 @@ import static org.junit.Assert.assertThat; import static org.junit.Assert.assertTrue; @TestForIssue(jiraKey = "HHH-13944") -@ServiceRegistry( - settings = @Setting( name = AvailableSettings.STATEMENT_INSPECTOR, value = "org.hibernate.testing.jdbc.SQLStatementInspector" ) -) @DomainModel( annotatedClasses = { Skill.class, Teacher.class, Student.class } ) -@SessionFactory +@SessionFactory( useCollectingStatementInspector = true ) public class OneToManySizeTest2 { @Test public void testSize(SessionFactoryScope scope) { diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/queryhint/OracleQueryHintTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/queryhint/OracleQueryHintTest.java index 2f6c99b050..91c0ee258b 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/queryhint/OracleQueryHintTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/queryhint/OracleQueryHintTest.java @@ -43,7 +43,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue; @DomainModel( annotatedClasses = { OracleQueryHintTest.Employee.class, OracleQueryHintTest.Department.class } ) -@SessionFactory(statementInspectorClass = SQLStatementInspector.class) +@SessionFactory(useCollectingStatementInspector = true) @ServiceRegistry( settings = @Setting(name = AvailableSettings.USE_SQL_COMMENTS, value = "true") ) @@ -67,7 +67,7 @@ public class OracleQueryHintTest { @Test public void testQueryHint(SessionFactoryScope scope) { - final SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); + final SQLStatementInspector statementInspector = scope.getCollectingStatementInspector(); statementInspector.clear(); // test Query w/ a simple Oracle optimizer hint @@ -141,7 +141,7 @@ public class OracleQueryHintTest { @Test @TestForIssue(jiraKey = "HHH-12362") public void testQueryHintAndComment(SessionFactoryScope scope) { - final SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); + final SQLStatementInspector statementInspector = scope.getCollectingStatementInspector(); statementInspector.clear(); scope.inTransaction( s -> { @@ -165,7 +165,7 @@ public class OracleQueryHintTest { @Test @TestForIssue(jiraKey = "HHH-13608") public void testQueryHintCaseInsensitive(SessionFactoryScope scope) { - final SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); + final SQLStatementInspector statementInspector = scope.getCollectingStatementInspector(); statementInspector.clear(); scope.inTransaction( s -> { diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/rowid/RowIdTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/rowid/RowIdTest.java index 6cd50bfad9..53af22f627 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/rowid/RowIdTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/rowid/RowIdTest.java @@ -30,7 +30,7 @@ import static org.junit.Assert.assertThat; * @author Nathan Xu */ @DomainModel( annotatedClasses = RowIdTest.Product.class ) -@SessionFactory(statementInspectorClass = SQLStatementInspector.class) +@SessionFactory(useCollectingStatementInspector = true) public class RowIdTest { @BeforeEach @@ -50,7 +50,7 @@ public class RowIdTest { scope.inTransaction( session -> { String rowId = scope.getSessionFactory().getJdbcServices().getDialect().rowId(""); - SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); + SQLStatementInspector statementInspector = scope.getCollectingStatementInspector(); statementInspector.clear(); Product product = session.find( Product.class, "1L" ); diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/sql/exec/EmbeddedWithManyToOneTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/sql/exec/EmbeddedWithManyToOneTest.java index 04e682043f..205ad2be6b 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/sql/exec/EmbeddedWithManyToOneTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/sql/exec/EmbeddedWithManyToOneTest.java @@ -44,7 +44,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue; ) @SessionFactory( generateStatistics = true, - statementInspectorClass = SQLStatementInspector.class) + useCollectingStatementInspector = true) public class EmbeddedWithManyToOneTest { @BeforeEach @@ -73,7 +73,7 @@ public class EmbeddedWithManyToOneTest { @Test public void testGet(SessionFactoryScope scope) { - SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); + SQLStatementInspector statementInspector = scope.getCollectingStatementInspector(); statementInspector.clear(); scope.inTransaction( session -> { @@ -87,7 +87,7 @@ public class EmbeddedWithManyToOneTest { @Test public void testHqlSelect(SessionFactoryScope scope) { - SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); + SQLStatementInspector statementInspector = scope.getCollectingStatementInspector(); statementInspector.clear(); scope.inTransaction( session -> { diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/sql/exec/manytoone/EntityWithManyToOneSelfReferenceTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/sql/exec/manytoone/EntityWithManyToOneSelfReferenceTest.java index 3df847458c..d525dd558a 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/sql/exec/manytoone/EntityWithManyToOneSelfReferenceTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/sql/exec/manytoone/EntityWithManyToOneSelfReferenceTest.java @@ -37,7 +37,7 @@ import static org.junit.Assert.assertTrue; } ) @ServiceRegistry -@SessionFactory(generateStatistics = true, statementInspectorClass = SQLStatementInspector.class) +@SessionFactory(generateStatistics = true, useCollectingStatementInspector = true) public class EntityWithManyToOneSelfReferenceTest { @BeforeEach @@ -96,7 +96,7 @@ public class EntityWithManyToOneSelfReferenceTest { @Test public void testGetEntity(SessionFactoryScope scope) { - SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); + SQLStatementInspector statementInspector = scope.getCollectingStatementInspector(); statementInspector.clear(); scope.inTransaction( session -> { diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/sql/exec/onetoone/bidirectional/EntityWithBidirectionalAssociationsOneOfWhichIsAJoinTableTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/sql/exec/onetoone/bidirectional/EntityWithBidirectionalAssociationsOneOfWhichIsAJoinTableTest.java index 296dc66b3a..b477446ef5 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/sql/exec/onetoone/bidirectional/EntityWithBidirectionalAssociationsOneOfWhichIsAJoinTableTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/sql/exec/onetoone/bidirectional/EntityWithBidirectionalAssociationsOneOfWhichIsAJoinTableTest.java @@ -45,7 +45,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue; } ) @ServiceRegistry -@SessionFactory(statementInspectorClass = SQLStatementInspector.class) +@SessionFactory(useCollectingStatementInspector = true) public class EntityWithBidirectionalAssociationsOneOfWhichIsAJoinTableTest { @BeforeEach @@ -78,7 +78,7 @@ public class EntityWithBidirectionalAssociationsOneOfWhichIsAJoinTableTest { @Test public void testGetParent(SessionFactoryScope scope) { - SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); + SQLStatementInspector statementInspector = scope.getCollectingStatementInspector(); statementInspector.clear(); scope.inTransaction( session -> { @@ -108,7 +108,7 @@ public class EntityWithBidirectionalAssociationsOneOfWhichIsAJoinTableTest { @Test public void testGetChild(SessionFactoryScope scope) { - SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); + SQLStatementInspector statementInspector = scope.getCollectingStatementInspector(); statementInspector.clear(); scope.inTransaction( session -> { final Male son = session.get( Male.class, 2 ); @@ -142,7 +142,7 @@ public class EntityWithBidirectionalAssociationsOneOfWhichIsAJoinTableTest { @Test public void testHqlSelectSon(SessionFactoryScope scope) { - SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); + SQLStatementInspector statementInspector = scope.getCollectingStatementInspector(); statementInspector.clear(); scope.inTransaction( session -> { @@ -168,7 +168,7 @@ public class EntityWithBidirectionalAssociationsOneOfWhichIsAJoinTableTest { public void testHqlSelectParent(SessionFactoryScope scope) { scope.inTransaction( session -> { - SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); + SQLStatementInspector statementInspector = scope.getCollectingStatementInspector(); statementInspector.clear(); final Parent parent = session.createQuery( "SELECT p FROM Parent p JOIN p.son WHERE p.id = :id", diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/sql/exec/onetoone/bidirectional/EntityWithBidirectionalOneToOneTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/sql/exec/onetoone/bidirectional/EntityWithBidirectionalOneToOneTest.java index 27f99b2e7f..d1951fad39 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/sql/exec/onetoone/bidirectional/EntityWithBidirectionalOneToOneTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/sql/exec/onetoone/bidirectional/EntityWithBidirectionalOneToOneTest.java @@ -16,7 +16,6 @@ import org.hibernate.validator.internal.util.Contracts; import org.hibernate.testing.jdbc.SQLStatementInspector; import org.hibernate.testing.orm.junit.DomainModel; -import org.hibernate.testing.orm.junit.FailureExpected; import org.hibernate.testing.orm.junit.ServiceRegistry; import org.hibernate.testing.orm.junit.SessionFactory; import org.hibernate.testing.orm.junit.SessionFactoryScope; @@ -48,7 +47,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue; } ) @ServiceRegistry -@SessionFactory(statementInspectorClass = SQLStatementInspector.class) +@SessionFactory(useCollectingStatementInspector = true) public class EntityWithBidirectionalOneToOneTest { @BeforeEach @@ -77,7 +76,7 @@ public class EntityWithBidirectionalOneToOneTest { @Test public void testGetMother(SessionFactoryScope scope) { - SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); + SQLStatementInspector statementInspector = scope.getCollectingStatementInspector(); statementInspector.clear(); scope.inTransaction( session -> { final Mother mother = session.get( Mother.class, 1 ); @@ -141,7 +140,7 @@ public class EntityWithBidirectionalOneToOneTest { session.save( adoptedChild ); } ); - SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); + SQLStatementInspector statementInspector = scope.getCollectingStatementInspector(); statementInspector.clear(); scope.inTransaction( session -> { final Mother mother = session.get( Mother.class, 4 ); @@ -194,7 +193,7 @@ public class EntityWithBidirectionalOneToOneTest { session.save( anotherChild ); } ); - SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); + SQLStatementInspector statementInspector = scope.getCollectingStatementInspector(); statementInspector.clear(); scope.inTransaction( session -> { final Mother mother = session.get( Mother.class, 4 ); @@ -236,7 +235,7 @@ public class EntityWithBidirectionalOneToOneTest { @Test public void testGetChild(SessionFactoryScope scope) { - SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); + SQLStatementInspector statementInspector = scope.getCollectingStatementInspector(); statementInspector.clear(); scope.inTransaction( session -> { final Child child = session.get( Child.class, 2 ); @@ -293,7 +292,7 @@ public class EntityWithBidirectionalOneToOneTest { session.get( AdoptedChild.class, 3 ).setBiologicalMother( mother ); } ); - SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); + SQLStatementInspector statementInspector = scope.getCollectingStatementInspector(); statementInspector.clear(); scope.inTransaction( session -> { final Child child = session.get( Child.class, 2 ); @@ -335,7 +334,7 @@ public class EntityWithBidirectionalOneToOneTest { @Test public void testGetAdoptedChild(SessionFactoryScope scope) { - SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); + SQLStatementInspector statementInspector = scope.getCollectingStatementInspector(); statementInspector.clear(); scope.inTransaction( session -> { final AdoptedChild adoptedChild = session.get( AdoptedChild.class, 3 ); @@ -407,7 +406,7 @@ public class EntityWithBidirectionalOneToOneTest { session.save( child3 ); } ); - SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); + SQLStatementInspector statementInspector = scope.getCollectingStatementInspector(); statementInspector.clear(); scope.inTransaction( session -> { final Child child = session.get( Child.class, 5 ); @@ -457,7 +456,7 @@ public class EntityWithBidirectionalOneToOneTest { @Test public void testHqlSelectMother(SessionFactoryScope scope) { - SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); + SQLStatementInspector statementInspector = scope.getCollectingStatementInspector(); statementInspector.clear(); scope.inTransaction( session -> { @@ -481,7 +480,7 @@ public class EntityWithBidirectionalOneToOneTest { @Test public void testHqlSelectChild(SessionFactoryScope scope) { - SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); + SQLStatementInspector statementInspector = scope.getCollectingStatementInspector(); statementInspector.clear(); scope.inTransaction( session -> { diff --git a/hibernate-testing/src/main/java/org/hibernate/testing/orm/jdbc/DefaultSQLStatementInspectorSettingProvider.java b/hibernate-testing/src/main/java/org/hibernate/testing/orm/jdbc/DefaultSQLStatementInspectorSettingProvider.java deleted file mode 100644 index 78764b86e6..0000000000 --- a/hibernate-testing/src/main/java/org/hibernate/testing/orm/jdbc/DefaultSQLStatementInspectorSettingProvider.java +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Hibernate, Relational Persistence for Idiomatic Java - * - * License: GNU Lesser General Public License (LGPL), version 2.1 or later - * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html - */ - -package org.hibernate.testing.orm.jdbc; - -import org.hibernate.testing.jdbc.SQLStatementInspector; -import org.hibernate.testing.orm.junit.SettingProvider; - -public class DefaultSQLStatementInspectorSettingProvider implements SettingProvider.Provider { - - @Override - public SQLStatementInspector getSetting() { - return new SQLStatementInspector(); - } -} diff --git a/hibernate-testing/src/main/java/org/hibernate/testing/orm/junit/AbstractEntityManagerFactoryScope.java b/hibernate-testing/src/main/java/org/hibernate/testing/orm/junit/AbstractEntityManagerFactoryScope.java index 9dc0ee5751..5efbf992b8 100644 --- a/hibernate-testing/src/main/java/org/hibernate/testing/orm/junit/AbstractEntityManagerFactoryScope.java +++ b/hibernate-testing/src/main/java/org/hibernate/testing/orm/junit/AbstractEntityManagerFactoryScope.java @@ -15,6 +15,7 @@ import org.hibernate.engine.spi.SessionFactoryImplementor; import org.hibernate.engine.spi.SessionImplementor; import org.hibernate.resource.jdbc.spi.StatementInspector; +import org.hibernate.testing.jdbc.SQLStatementInspector; import org.hibernate.testing.orm.transaction.TransactionUtil; import org.junit.jupiter.api.extension.ExtensionContext; @@ -55,6 +56,11 @@ abstract class AbstractEntityManagerFactoryScope implements EntityManagerFactory return (T) getStatementInspector(); } + @Override + public SQLStatementInspector getCollectingStatementInspector() { + return getStatementInspector( SQLStatementInspector.class ); + } + @Override public void close() { if ( !active ) { diff --git a/hibernate-testing/src/main/java/org/hibernate/testing/orm/junit/EntityManagerFactoryExtension.java b/hibernate-testing/src/main/java/org/hibernate/testing/orm/junit/EntityManagerFactoryExtension.java index cd8fbf901a..54a7d37e31 100644 --- a/hibernate-testing/src/main/java/org/hibernate/testing/orm/junit/EntityManagerFactoryExtension.java +++ b/hibernate-testing/src/main/java/org/hibernate/testing/orm/junit/EntityManagerFactoryExtension.java @@ -31,6 +31,7 @@ import org.hibernate.tool.schema.Action; import org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator; import org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.ActionGrouping; +import org.hibernate.testing.jdbc.SQLStatementInspector; import org.hibernate.testing.jdbc.SharedDriverManagerConnectionProviderImpl; import org.hibernate.testing.orm.domain.DomainModelDescriptor; import org.hibernate.testing.orm.domain.StandardDomainModel; @@ -164,7 +165,6 @@ public class EntityManagerFactoryExtension final Map integrationSettings = new HashMap<>(); - integrationSettings.put( PersistentTableStrategy.DROP_ID_TABLES, "true" ); integrationSettings.put( GlobalTemporaryTableMutationStrategy.DROP_ID_TABLES, "true" ); integrationSettings.put( LocalTemporaryTableMutationStrategy.DROP_ID_TABLES, "true" ); @@ -190,6 +190,15 @@ public class EntityManagerFactoryExtension } } + // statement inspector + if ( emfAnn.useCollectingStatementInspector() ) { + String inspectorSetting = (String) integrationSettings.get( AvailableSettings.STATEMENT_INSPECTOR ); + if ( !(inspectorSetting == null || inspectorSetting.isBlank()) ) { + log.warn( String.format( "Overriding the explicit \"%1s\" statement inspector setting", inspectorSetting ) ); + } + integrationSettings.put( AvailableSettings.STATEMENT_INSPECTOR, new SQLStatementInspector() ); + } + final EntityManagerFactoryScopeImpl scope = new EntityManagerFactoryScopeImpl( pui, integrationSettings ); locateExtensionStore( testInstance, context ).put( EMF_KEY, scope ); diff --git a/hibernate-testing/src/main/java/org/hibernate/testing/orm/junit/EntityManagerFactoryScope.java b/hibernate-testing/src/main/java/org/hibernate/testing/orm/junit/EntityManagerFactoryScope.java index 6225db1dc7..dd025455f8 100644 --- a/hibernate-testing/src/main/java/org/hibernate/testing/orm/junit/EntityManagerFactoryScope.java +++ b/hibernate-testing/src/main/java/org/hibernate/testing/orm/junit/EntityManagerFactoryScope.java @@ -13,6 +13,8 @@ import jakarta.persistence.EntityManagerFactory; import org.hibernate.resource.jdbc.spi.StatementInspector; +import org.hibernate.testing.jdbc.SQLStatementInspector; + /** * @author Steve Ebersole */ @@ -22,6 +24,7 @@ public interface EntityManagerFactoryScope { StatementInspector getStatementInspector(); T getStatementInspector(Class type); + SQLStatementInspector getCollectingStatementInspector(); void inEntityManager(Consumer action); void inTransaction(Consumer action); diff --git a/hibernate-testing/src/main/java/org/hibernate/testing/orm/junit/Jpa.java b/hibernate-testing/src/main/java/org/hibernate/testing/orm/junit/Jpa.java index 0c5ae66c46..20b715f7de 100644 --- a/hibernate-testing/src/main/java/org/hibernate/testing/orm/junit/Jpa.java +++ b/hibernate-testing/src/main/java/org/hibernate/testing/orm/junit/Jpa.java @@ -17,8 +17,8 @@ import jakarta.persistence.ValidationMode; import jakarta.persistence.spi.PersistenceUnitTransactionType; import org.hibernate.jpa.spi.JpaCompliance; -import org.hibernate.resource.jdbc.spi.StatementInspector; +import org.hibernate.testing.jdbc.SQLStatementInspector; import org.hibernate.testing.orm.domain.DomainModelDescriptor; import org.hibernate.testing.orm.domain.StandardDomainModel; import org.junit.jupiter.api.TestInstance; @@ -122,4 +122,12 @@ public @interface Jpa { String[] annotatedClassNames() default {}; String[] annotatedPackageNames() default {}; String[] xmlMappings() default {}; + + /** + * Shorthand for adding {@code @Setting( name = AvailableSettings.STATEMENT_INSPECTOR, value = "org.hibernate.testing.jdbc.SQLStatementInspector"} + * to the integration settings. + * Note: if the statement inspector is also explicitly specified as a setting, it will be overridden by the shortcut + * @see SQLStatementInspector + */ + boolean useCollectingStatementInspector() default false; }