Add useCollectingStatementInspector() to @Jpa and refactor tests that can use it to do so

Signed-off-by: Jan Schatteman <jschatte@redhat.com>
This commit is contained in:
Jan Schatteman 2023-01-04 23:48:15 +01:00 committed by Jan Schatteman
parent 1e87b3399f
commit d4cc873ad0
71 changed files with 278 additions and 341 deletions

View File

@ -26,7 +26,7 @@ import static org.junit.jupiter.api.Assertions.fail;
annotatedClasses = { annotatedClasses = {
Card.class, CardField.class, Key.class Card.class, CardField.class, Key.class
}) })
@SessionFactory(statementInspectorClass = SQLStatementInspector.class) @SessionFactory(useCollectingStatementInspector = true)
public class EagerKeyManyToOneTest { public class EagerKeyManyToOneTest {
public static final String CARD_ID = "cardId"; public static final String CARD_ID = "cardId";
public static final String CARD_MODEL = "Gran Torino"; 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 // 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 // and http://opensource.atlassian.com/projects/hibernate/browse/HHH-4147
SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); SQLStatementInspector statementInspector = scope.getCollectingStatementInspector();
statementInspector.clear(); statementInspector.clear();
scope.inTransaction( scope.inTransaction(
session -> { session -> {

View File

@ -24,7 +24,7 @@ import static org.junit.jupiter.api.Assertions.fail;
annotatedClasses = { annotatedClasses = {
Card.class, CardField.class, Key.class Card.class, CardField.class, Key.class
}) })
@SessionFactory(statementInspectorClass = SQLStatementInspector.class) @SessionFactory(useCollectingStatementInspector = true)
public class EagerKeyManyToOneTest { public class EagerKeyManyToOneTest {
public static final String CARD_ID = "cardId"; public static final String CARD_ID = "cardId";
public static final String KEY_ID = "keyId"; public static final String KEY_ID = "keyId";
@ -59,7 +59,7 @@ public class EagerKeyManyToOneTest {
@Test @Test
public void testLoadEntityWithEagerFetchingToKeyManyToOneReferenceBackToSelf(SessionFactoryScope scope) { public void testLoadEntityWithEagerFetchingToKeyManyToOneReferenceBackToSelf(SessionFactoryScope scope) {
SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); SQLStatementInspector statementInspector = scope.getCollectingStatementInspector();
statementInspector.clear(); statementInspector.clear();
scope.inTransaction( scope.inTransaction(
session -> { session -> {

View File

@ -36,7 +36,7 @@ import static org.junit.jupiter.api.Assertions.assertSame;
EntityTest.class EntityTest.class
} }
) )
@SessionFactory(statementInspectorClass = SQLStatementInspector.class) @SessionFactory(useCollectingStatementInspector = true)
public class EmbeddableBiDirectionalSelfReferenceTest { public class EmbeddableBiDirectionalSelfReferenceTest {
@BeforeEach @BeforeEach
@ -70,7 +70,7 @@ public class EmbeddableBiDirectionalSelfReferenceTest {
@Test @Test
public void testGet(SessionFactoryScope scope) { public void testGet(SessionFactoryScope scope) {
SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); SQLStatementInspector statementInspector = scope.getCollectingStatementInspector();
statementInspector.clear(); statementInspector.clear();
scope.inTransaction( scope.inTransaction(
session -> { session -> {
@ -111,7 +111,7 @@ public class EmbeddableBiDirectionalSelfReferenceTest {
} }
); );
SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); SQLStatementInspector statementInspector = scope.getCollectingStatementInspector();
statementInspector.clear(); statementInspector.clear();
scope.inTransaction( scope.inTransaction(
session -> { session -> {

View File

@ -32,7 +32,7 @@ import static org.junit.jupiter.api.Assertions.assertSame;
EmbeddableWithManyToOneCircularityTest.EntityTest2.class EmbeddableWithManyToOneCircularityTest.EntityTest2.class
} }
) )
@SessionFactory(statementInspectorClass = SQLStatementInspector.class) @SessionFactory(useCollectingStatementInspector = true)
public class EmbeddableWithManyToOneCircularityTest { public class EmbeddableWithManyToOneCircularityTest {
@BeforeEach @BeforeEach
@ -76,7 +76,7 @@ public class EmbeddableWithManyToOneCircularityTest {
@Test @Test
public void testGet(SessionFactoryScope scope) { public void testGet(SessionFactoryScope scope) {
SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); SQLStatementInspector statementInspector = scope.getCollectingStatementInspector();
statementInspector.clear(); statementInspector.clear();
scope.inTransaction( scope.inTransaction(
session -> { session -> {

View File

@ -34,7 +34,7 @@ import static org.junit.jupiter.api.Assertions.assertSame;
EmbeddableWithManyToOneTest.EntityTest2.class EmbeddableWithManyToOneTest.EntityTest2.class
} }
) )
@SessionFactory(statementInspectorClass = SQLStatementInspector.class) @SessionFactory(useCollectingStatementInspector = true)
public class EmbeddableWithManyToOneTest { public class EmbeddableWithManyToOneTest {
@BeforeEach @BeforeEach
@ -78,7 +78,7 @@ public class EmbeddableWithManyToOneTest {
@Test @Test
public void testGet(SessionFactoryScope scope) { public void testGet(SessionFactoryScope scope) {
SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); SQLStatementInspector statementInspector = scope.getCollectingStatementInspector();
statementInspector.clear(); statementInspector.clear();
scope.inTransaction( scope.inTransaction(
session -> { session -> {
@ -112,7 +112,7 @@ public class EmbeddableWithManyToOneTest {
session.save( entityTest2 ); session.save( entityTest2 );
} }
); );
SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); SQLStatementInspector statementInspector = scope.getCollectingStatementInspector();
statementInspector.clear(); statementInspector.clear();
scope.inTransaction( scope.inTransaction(
session -> { session -> {
@ -152,7 +152,7 @@ public class EmbeddableWithManyToOneTest {
session.save( entityTest2 ); session.save( entityTest2 );
} }
); );
SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); SQLStatementInspector statementInspector = scope.getCollectingStatementInspector();
statementInspector.clear(); statementInspector.clear();
scope.inTransaction( scope.inTransaction(
session -> { session -> {

View File

@ -31,7 +31,7 @@ import org.junit.jupiter.api.Test;
Child.class Child.class
} }
) )
@SessionFactory(statementInspectorClass = SQLStatementInspector.class) @SessionFactory(useCollectingStatementInspector = true)
public class NotOptionalManyToOneTest { public class NotOptionalManyToOneTest {
@BeforeEach @BeforeEach
@ -59,7 +59,7 @@ public class NotOptionalManyToOneTest {
@Test @Test
public void testInnerJoinIsUsed(SessionFactoryScope scope) { public void testInnerJoinIsUsed(SessionFactoryScope scope) {
SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); SQLStatementInspector statementInspector = scope.getCollectingStatementInspector();
statementInspector.clear(); statementInspector.clear();
scope.inTransaction( scope.inTransaction(
session -> { session -> {

View File

@ -28,13 +28,13 @@ import static org.junit.jupiter.api.Assertions.assertThrows;
OneToManyJoinColumnsUniquenessTest.EntityB.class, OneToManyJoinColumnsUniquenessTest.EntityB.class,
} }
) )
@SessionFactory(statementInspectorClass = SQLStatementInspector.class) @SessionFactory(useCollectingStatementInspector = true)
@TestForIssue(jiraKey = "HHH-15091") @TestForIssue(jiraKey = "HHH-15091")
public class OneToManyJoinColumnsUniquenessTest { public class OneToManyJoinColumnsUniquenessTest {
@Test @Test
public void testInsertWithNullAssociationThrowPersistenceException(SessionFactoryScope scope) { public void testInsertWithNullAssociationThrowPersistenceException(SessionFactoryScope scope) {
SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); SQLStatementInspector statementInspector = scope.getCollectingStatementInspector();
statementInspector.clear(); statementInspector.clear();
assertThrows( assertThrows(
PersistenceException.class, () -> PersistenceException.class, () ->

View File

@ -20,7 +20,6 @@ import org.hibernate.testing.orm.junit.DomainModel;
import org.hibernate.testing.orm.junit.SessionFactory; import org.hibernate.testing.orm.junit.SessionFactory;
import org.hibernate.testing.orm.junit.SessionFactoryScope; import org.hibernate.testing.orm.junit.SessionFactoryScope;
import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import jakarta.persistence.Entity; import jakarta.persistence.Entity;
@ -44,7 +43,7 @@ import static org.assertj.core.api.Assertions.assertThat;
} }
) )
@SessionFactory( @SessionFactory(
statementInspectorClass = SQLStatementInspector.class useCollectingStatementInspector = true
) )
public class QueryListParametersWithFetchSubSelectTest { public class QueryListParametersWithFetchSubSelectTest {
@ -65,7 +64,7 @@ public class QueryListParametersWithFetchSubSelectTest {
@Test @Test
public void simpleTest(SessionFactoryScope scope) { public void simpleTest(SessionFactoryScope scope) {
final SQLStatementInspector sqlStatementInterceptor = (SQLStatementInspector) scope.getStatementInspector(); final SQLStatementInspector sqlStatementInterceptor = scope.getCollectingStatementInspector();
sqlStatementInterceptor.clear(); sqlStatementInterceptor.clear();
scope.inTransaction( s -> { scope.inTransaction( s -> {
@ -85,7 +84,7 @@ public class QueryListParametersWithFetchSubSelectTest {
@Test @Test
@TestForIssue(jiraKey = "HHH-14439") @TestForIssue(jiraKey = "HHH-14439")
public void reusingQueryWithFewerNamedParameters(SessionFactoryScope scope) { public void reusingQueryWithFewerNamedParameters(SessionFactoryScope scope) {
final SQLStatementInspector sqlStatementInterceptor = (SQLStatementInspector) scope.getStatementInspector(); final SQLStatementInspector sqlStatementInterceptor = scope.getCollectingStatementInspector();
sqlStatementInterceptor.clear(); sqlStatementInterceptor.clear();
@ -120,7 +119,7 @@ public class QueryListParametersWithFetchSubSelectTest {
@Test @Test
@TestForIssue(jiraKey = "HHH-14439") @TestForIssue(jiraKey = "HHH-14439")
public void reusingQueryWithFewerOrdinalParameters(SessionFactoryScope scope) { public void reusingQueryWithFewerOrdinalParameters(SessionFactoryScope scope) {
final SQLStatementInspector sqlStatementInterceptor = (SQLStatementInspector) scope.getStatementInspector(); final SQLStatementInspector sqlStatementInterceptor = scope.getCollectingStatementInspector();
sqlStatementInterceptor.clear(); sqlStatementInterceptor.clear();

View File

@ -22,7 +22,7 @@ import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
@DomainModel( @DomainModel(
annotatedClasses = BatchNoUseJdbcMetadataTest.Person.class annotatedClasses = BatchNoUseJdbcMetadataTest.Person.class
) )
@SessionFactory(statementInspectorClass = SQLStatementInspector.class) @SessionFactory(useCollectingStatementInspector = true)
@ServiceRegistry( @ServiceRegistry(
settings = { settings = {
@Setting(name = AvailableSettings.STATEMENT_BATCH_SIZE, value = "5"), @Setting(name = AvailableSettings.STATEMENT_BATCH_SIZE, value = "5"),
@ -35,7 +35,7 @@ public class BatchNoUseJdbcMetadataTest {
@Test @Test
public void testBatching(SessionFactoryScope scope) { public void testBatching(SessionFactoryScope scope) {
final SQLStatementInspector sqlStatementInterceptor = (SQLStatementInspector) scope.getStatementInspector(); final SQLStatementInspector sqlStatementInterceptor = scope.getCollectingStatementInspector();
sqlStatementInterceptor.clear(); sqlStatementInterceptor.clear();
scope.inTransaction( scope.inTransaction(
session -> { session -> {

View File

@ -30,7 +30,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
EagerManyToOneBatchTest.Parent.class EagerManyToOneBatchTest.Parent.class
} }
) )
@SessionFactory(statementInspectorClass = SQLStatementInspector.class) @SessionFactory(useCollectingStatementInspector = true)
@ServiceRegistry( @ServiceRegistry(
settings = @Setting(name = AvailableSettings.DEFAULT_BATCH_FETCH_SIZE, value = "2") settings = @Setting(name = AvailableSettings.DEFAULT_BATCH_FETCH_SIZE, value = "2")
) )
@ -67,7 +67,7 @@ public class EagerManyToOneBatchTest {
@Test @Test
public void testSelect(SessionFactoryScope scope) { public void testSelect(SessionFactoryScope scope) {
SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); SQLStatementInspector statementInspector = scope.getCollectingStatementInspector();
statementInspector.clear(); statementInspector.clear();
scope.inTransaction( scope.inTransaction(
session -> { session -> {

View File

@ -31,7 +31,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
LazyManyToOneBatchTest.Parent.class LazyManyToOneBatchTest.Parent.class
} }
) )
@SessionFactory(statementInspectorClass = SQLStatementInspector.class) @SessionFactory(useCollectingStatementInspector = true)
@ServiceRegistry( @ServiceRegistry(
settings = @Setting(name = AvailableSettings.DEFAULT_BATCH_FETCH_SIZE, value = "2") settings = @Setting(name = AvailableSettings.DEFAULT_BATCH_FETCH_SIZE, value = "2")
) )
@ -67,7 +67,7 @@ public class LazyManyToOneBatchTest {
@Test @Test
public void testSelect(SessionFactoryScope scope) { public void testSelect(SessionFactoryScope scope) {
SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); SQLStatementInspector statementInspector = scope.getCollectingStatementInspector();
statementInspector.clear(); statementInspector.clear();
scope.inTransaction( scope.inTransaction(
session -> { session -> {

View File

@ -38,7 +38,7 @@ import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
@DomainModel( @DomainModel(
annotatedClasses = { EagerManyToOneStreamTest.Child.class, EagerManyToOneStreamTest.Parent.class } 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")) @ServiceRegistry(settings = @Setting(name = AvailableSettings.DEFAULT_BATCH_FETCH_SIZE, value = "2"))
@JiraKey("HHH-15449") @JiraKey("HHH-15449")
public class EagerManyToOneStreamTest { public class EagerManyToOneStreamTest {
@ -72,7 +72,7 @@ public class EagerManyToOneStreamTest {
@Test @Test
public void testGetResultStreamCollectSingleResult(SessionFactoryScope scope) { public void testGetResultStreamCollectSingleResult(SessionFactoryScope scope) {
final SQLStatementInspector sqlStatementInterceptor = (SQLStatementInspector) scope.getStatementInspector(); final SQLStatementInspector sqlStatementInterceptor = scope.getCollectingStatementInspector();
sqlStatementInterceptor.clear(); sqlStatementInterceptor.clear();
scope.inTransaction( scope.inTransaction(
session -> { session -> {
@ -100,7 +100,7 @@ public class EagerManyToOneStreamTest {
@Test @Test
public void testGetResultStreamCollect(SessionFactoryScope scope) { public void testGetResultStreamCollect(SessionFactoryScope scope) {
final SQLStatementInspector sqlStatementInterceptor = (SQLStatementInspector) scope.getStatementInspector(); final SQLStatementInspector sqlStatementInterceptor = scope.getCollectingStatementInspector();
sqlStatementInterceptor.clear(); sqlStatementInterceptor.clear();
scope.inTransaction( scope.inTransaction(
session -> { session -> {

View File

@ -35,7 +35,7 @@ import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
@DomainModel( @DomainModel(
annotatedClasses = { EagerManyToOneTest.Child.class, EagerManyToOneTest.Parent.class } 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")) @ServiceRegistry(settings = @Setting(name = AvailableSettings.DEFAULT_BATCH_FETCH_SIZE, value = "2"))
@JiraKey("HHH-15449") @JiraKey("HHH-15449")
public class EagerManyToOneTest { public class EagerManyToOneTest {
@ -69,7 +69,7 @@ public class EagerManyToOneTest {
@Test @Test
public void testGetResultList(SessionFactoryScope scope) { public void testGetResultList(SessionFactoryScope scope) {
final SQLStatementInspector sqlStatementInterceptor = (SQLStatementInspector) scope.getStatementInspector(); final SQLStatementInspector sqlStatementInterceptor = scope.getCollectingStatementInspector();
sqlStatementInterceptor.clear(); sqlStatementInterceptor.clear();
scope.inTransaction( scope.inTransaction(
session -> { session -> {

View File

@ -39,7 +39,7 @@ import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
@DomainModel( @DomainModel(
annotatedClasses = { LazyManyToOneStreamTest.Child.class, LazyManyToOneStreamTest.Parent.class } 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")) @ServiceRegistry(settings = @Setting(name = AvailableSettings.DEFAULT_BATCH_FETCH_SIZE, value = "2"))
@JiraKey("HHH-15449") @JiraKey("HHH-15449")
public class LazyManyToOneStreamTest { public class LazyManyToOneStreamTest {
@ -73,7 +73,7 @@ public class LazyManyToOneStreamTest {
@Test @Test
public void testGetResultStreamCollectSingleResult(SessionFactoryScope scope) { public void testGetResultStreamCollectSingleResult(SessionFactoryScope scope) {
final SQLStatementInspector sqlStatementInterceptor = (SQLStatementInspector) scope.getStatementInspector(); final SQLStatementInspector sqlStatementInterceptor = scope.getCollectingStatementInspector();
sqlStatementInterceptor.clear(); sqlStatementInterceptor.clear();
scope.inTransaction( scope.inTransaction(
session -> { session -> {
@ -100,7 +100,7 @@ public class LazyManyToOneStreamTest {
@Test @Test
public void testGetResultStreamCollect(SessionFactoryScope scope) { public void testGetResultStreamCollect(SessionFactoryScope scope) {
final SQLStatementInspector sqlStatementInterceptor = (SQLStatementInspector) scope.getStatementInspector(); final SQLStatementInspector sqlStatementInterceptor = scope.getCollectingStatementInspector();
sqlStatementInterceptor.clear(); sqlStatementInterceptor.clear();
scope.inTransaction( scope.inTransaction(
session -> { session -> {

View File

@ -36,7 +36,7 @@ import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
@DomainModel( @DomainModel(
annotatedClasses = { LazyManyToOneTest.Child.class, LazyManyToOneTest.Parent.class } 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")) @ServiceRegistry(settings = @Setting(name = AvailableSettings.DEFAULT_BATCH_FETCH_SIZE, value = "2"))
@JiraKey("HHH-15449") @JiraKey("HHH-15449")
public class LazyManyToOneTest { public class LazyManyToOneTest {
@ -70,7 +70,7 @@ public class LazyManyToOneTest {
@Test @Test
public void testGetResultList(SessionFactoryScope scope) { public void testGetResultList(SessionFactoryScope scope) {
final SQLStatementInspector sqlStatementInterceptor = (SQLStatementInspector) scope.getStatementInspector(); final SQLStatementInspector sqlStatementInterceptor = scope.getCollectingStatementInspector();
sqlStatementInterceptor.clear(); sqlStatementInterceptor.clear();
scope.inTransaction( scope.inTransaction(
session -> { session -> {

View File

@ -39,7 +39,6 @@ import org.hibernate.testing.orm.junit.Setting;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test; 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.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertNotNull;
@ -52,7 +51,7 @@ import static org.junit.jupiter.api.Assertions.assertNotNull;
CascadeMergeToProxyEntityCopyAllowedTest.Speaker.class CascadeMergeToProxyEntityCopyAllowedTest.Speaker.class
} }
) )
@SessionFactory(statementInspectorClass = SQLStatementInspector.class) @SessionFactory(useCollectingStatementInspector = true)
@ServiceRegistry( @ServiceRegistry(
settings = { settings = {
@Setting( @Setting(
@ -67,7 +66,7 @@ public class CascadeMergeToProxyEntityCopyAllowedTest {
public void test(SessionFactoryScope scope) { public void test(SessionFactoryScope scope) {
final Event root = (Event) persistEntity( scope, new Event( null, defaultProject ) ); final Event root = (Event) persistEntity( scope, new Event( null, defaultProject ) );
SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); SQLStatementInspector statementInspector = scope.getCollectingStatementInspector();
statementInspector.clear(); statementInspector.clear();
Event rootFromDB = scope.fromTransaction( Event rootFromDB = scope.fromTransaction(
session -> { session -> {

View File

@ -35,7 +35,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
"org/hibernate/orm/test/cid/Product.hbm.xml" "org/hibernate/orm/test/cid/Product.hbm.xml"
} }
) )
@SessionFactory(statementInspectorClass = SQLStatementInspector.class) @SessionFactory(useCollectingStatementInspector = true)
public class CompositeIdTest { public class CompositeIdTest {
@AfterEach @AfterEach
@ -90,7 +90,7 @@ public class CompositeIdTest {
} }
); );
final SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); final SQLStatementInspector statementInspector = scope.getCollectingStatementInspector();
statementInspector.clear(); statementInspector.clear();
scope.inTransaction( scope.inTransaction(

View File

@ -17,7 +17,6 @@ import jakarta.persistence.Table;
import org.hibernate.testing.jdbc.SQLStatementInspector; import org.hibernate.testing.jdbc.SQLStatementInspector;
import org.hibernate.testing.orm.junit.DomainModel; 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.SessionFactory;
import org.hibernate.testing.orm.junit.SessionFactoryScope; import org.hibernate.testing.orm.junit.SessionFactoryScope;
import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.AfterEach;
@ -37,7 +36,7 @@ import static org.hamcrest.core.IsNull.notNullValue;
EagerManyToOneEmbeddedIdFKTest.SystemUser.class EagerManyToOneEmbeddedIdFKTest.SystemUser.class
} }
) )
@SessionFactory(statementInspectorClass = SQLStatementInspector.class) @SessionFactory(useCollectingStatementInspector = true)
public class EagerManyToOneEmbeddedIdFKTest { public class EagerManyToOneEmbeddedIdFKTest {
@BeforeEach @BeforeEach
@ -68,7 +67,7 @@ public class EagerManyToOneEmbeddedIdFKTest {
@Test @Test
public void testGet(SessionFactoryScope scope) { public void testGet(SessionFactoryScope scope) {
SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); SQLStatementInspector statementInspector = scope.getCollectingStatementInspector();
statementInspector.clear(); statementInspector.clear();
scope.inTransaction( scope.inTransaction(
session -> { session -> {
@ -84,7 +83,7 @@ public class EagerManyToOneEmbeddedIdFKTest {
@Test @Test
public void testHql(SessionFactoryScope scope) { public void testHql(SessionFactoryScope scope) {
SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); SQLStatementInspector statementInspector = scope.getCollectingStatementInspector();
statementInspector.clear(); statementInspector.clear();
scope.inTransaction( scope.inTransaction(
session -> { session -> {

View File

@ -42,7 +42,7 @@ import static org.junit.jupiter.api.Assertions.assertFalse;
LazyManyToOneEmbeddedIdWithToOneFKTest.Subsystem.class LazyManyToOneEmbeddedIdWithToOneFKTest.Subsystem.class
} }
) )
@SessionFactory(statementInspectorClass = SQLStatementInspector.class) @SessionFactory(useCollectingStatementInspector = true)
public class LazyManyToOneEmbeddedIdWithToOneFKTest { public class LazyManyToOneEmbeddedIdWithToOneFKTest {
@BeforeEach @BeforeEach
@ -76,7 +76,7 @@ public class LazyManyToOneEmbeddedIdWithToOneFKTest {
@Test @Test
public void testGet(SessionFactoryScope scope) { public void testGet(SessionFactoryScope scope) {
SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); SQLStatementInspector statementInspector = scope.getCollectingStatementInspector();
statementInspector.clear(); statementInspector.clear();
scope.inTransaction( scope.inTransaction(
session -> { session -> {
@ -116,7 +116,7 @@ public class LazyManyToOneEmbeddedIdWithToOneFKTest {
@Test @Test
public void testHql(SessionFactoryScope scope) { public void testHql(SessionFactoryScope scope) {
SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); SQLStatementInspector statementInspector = scope.getCollectingStatementInspector();
statementInspector.clear(); statementInspector.clear();
scope.inTransaction( scope.inTransaction(
session -> { session -> {
@ -155,7 +155,7 @@ public class LazyManyToOneEmbeddedIdWithToOneFKTest {
@Test @Test
public void testHqlJoin(SessionFactoryScope scope) { public void testHqlJoin(SessionFactoryScope scope) {
SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); SQLStatementInspector statementInspector = scope.getCollectingStatementInspector();
statementInspector.clear(); statementInspector.clear();
scope.inTransaction( scope.inTransaction(
session -> { session -> {
@ -176,7 +176,7 @@ public class LazyManyToOneEmbeddedIdWithToOneFKTest {
@Test @Test
public void testHqlJoinFetch(SessionFactoryScope scope) { public void testHqlJoinFetch(SessionFactoryScope scope) {
SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); SQLStatementInspector statementInspector = scope.getCollectingStatementInspector();
statementInspector.clear(); statementInspector.clear();
scope.inTransaction( scope.inTransaction(
session -> { session -> {
@ -201,7 +201,7 @@ public class LazyManyToOneEmbeddedIdWithToOneFKTest {
@Test @Test
public void testHql2(SessionFactoryScope scope) { public void testHql2(SessionFactoryScope scope) {
SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); SQLStatementInspector statementInspector = scope.getCollectingStatementInspector();
statementInspector.clear(); statementInspector.clear();
scope.inTransaction( scope.inTransaction(
session -> { session -> {

View File

@ -42,7 +42,7 @@ import static org.junit.Assert.assertTrue;
ManyToOneEmbeddedIdWithLazyToOneFKTest.Subsystem.class ManyToOneEmbeddedIdWithLazyToOneFKTest.Subsystem.class
} }
) )
@SessionFactory(statementInspectorClass = SQLStatementInspector.class) @SessionFactory(useCollectingStatementInspector = true)
public class ManyToOneEmbeddedIdWithLazyToOneFKTest { public class ManyToOneEmbeddedIdWithLazyToOneFKTest {
@BeforeEach @BeforeEach
@ -76,7 +76,7 @@ public class ManyToOneEmbeddedIdWithLazyToOneFKTest {
@Test @Test
public void testGet(SessionFactoryScope scope) { public void testGet(SessionFactoryScope scope) {
SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); SQLStatementInspector statementInspector = scope.getCollectingStatementInspector();
statementInspector.clear(); statementInspector.clear();
scope.inTransaction( scope.inTransaction(
session -> { session -> {
@ -110,7 +110,7 @@ public class ManyToOneEmbeddedIdWithLazyToOneFKTest {
@Test @Test
public void testHql(SessionFactoryScope scope) { public void testHql(SessionFactoryScope scope) {
SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); SQLStatementInspector statementInspector = scope.getCollectingStatementInspector();
statementInspector.clear(); statementInspector.clear();
/* /*
select select
@ -169,7 +169,7 @@ public class ManyToOneEmbeddedIdWithLazyToOneFKTest {
@Test @Test
public void testHqlJoin(SessionFactoryScope scope) { public void testHqlJoin(SessionFactoryScope scope) {
SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); SQLStatementInspector statementInspector = scope.getCollectingStatementInspector();
statementInspector.clear(); statementInspector.clear();
scope.inTransaction( scope.inTransaction(
session -> { session -> {
@ -203,7 +203,7 @@ public class ManyToOneEmbeddedIdWithLazyToOneFKTest {
@Test @Test
public void testHqlJoinFetch(SessionFactoryScope scope) { public void testHqlJoinFetch(SessionFactoryScope scope) {
SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); SQLStatementInspector statementInspector = scope.getCollectingStatementInspector();
statementInspector.clear(); statementInspector.clear();
scope.inTransaction( scope.inTransaction(
session -> { session -> {
@ -236,7 +236,7 @@ public class ManyToOneEmbeddedIdWithLazyToOneFKTest {
@Test @Test
public void testHql2(SessionFactoryScope scope) { public void testHql2(SessionFactoryScope scope) {
SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); SQLStatementInspector statementInspector = scope.getCollectingStatementInspector();
statementInspector.clear(); statementInspector.clear();
scope.inTransaction( scope.inTransaction(
session -> { session -> {

View File

@ -40,12 +40,12 @@ import static org.junit.Assert.assertTrue;
ManyToOneEmbeddedIdWithToOneFKTest.DataCenter.class ManyToOneEmbeddedIdWithToOneFKTest.DataCenter.class
} }
) )
@SessionFactory(statementInspectorClass = SQLStatementInspector.class) @SessionFactory(useCollectingStatementInspector = true)
public class ManyToOneEmbeddedIdWithToOneFKTest { public class ManyToOneEmbeddedIdWithToOneFKTest {
@Test @Test
public void testGet(SessionFactoryScope scope) { public void testGet(SessionFactoryScope scope) {
SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); SQLStatementInspector statementInspector = scope.getCollectingStatementInspector();
statementInspector.clear(); statementInspector.clear();
scope.inTransaction( scope.inTransaction(
session -> { session -> {
@ -75,7 +75,7 @@ public class ManyToOneEmbeddedIdWithToOneFKTest {
@Test @Test
public void testHql(SessionFactoryScope scope) { public void testHql(SessionFactoryScope scope) {
SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); SQLStatementInspector statementInspector = scope.getCollectingStatementInspector();
statementInspector.clear(); statementInspector.clear();
scope.inTransaction( scope.inTransaction(
session -> { session -> {
@ -110,7 +110,7 @@ public class ManyToOneEmbeddedIdWithToOneFKTest {
@Test @Test
public void testHqlJoin(SessionFactoryScope scope) { public void testHqlJoin(SessionFactoryScope scope) {
SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); SQLStatementInspector statementInspector = scope.getCollectingStatementInspector();
statementInspector.clear(); statementInspector.clear();
scope.inTransaction( scope.inTransaction(
session -> { session -> {
@ -129,7 +129,7 @@ public class ManyToOneEmbeddedIdWithToOneFKTest {
@Test @Test
public void testHqlJoinFetch(SessionFactoryScope scope) { public void testHqlJoinFetch(SessionFactoryScope scope) {
SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); SQLStatementInspector statementInspector = scope.getCollectingStatementInspector();
statementInspector.clear(); statementInspector.clear();
scope.inTransaction( scope.inTransaction(
session -> { session -> {
@ -168,7 +168,7 @@ public class ManyToOneEmbeddedIdWithToOneFKTest {
@Test @Test
public void testHql2(SessionFactoryScope scope) { public void testHql2(SessionFactoryScope scope) {
SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); SQLStatementInspector statementInspector = scope.getCollectingStatementInspector();
statementInspector.clear(); statementInspector.clear();
scope.inTransaction( scope.inTransaction(
session -> { session -> {

View File

@ -41,13 +41,13 @@ import static org.hamcrest.MatcherAssert.assertThat;
EntityGraphWithFetchAnnotationTest.Tag.class EntityGraphWithFetchAnnotationTest.Tag.class
} }
) )
@SessionFactory(statementInspectorClass = SQLStatementInspector.class) @SessionFactory(useCollectingStatementInspector = true)
public class EntityGraphWithFetchAnnotationTest { public class EntityGraphWithFetchAnnotationTest {
@Test @Test
@TestForIssue(jiraKey = "HHH-10485") @TestForIssue(jiraKey = "HHH-10485")
void testWithoutEntityGraph(SessionFactoryScope scope) { void testWithoutEntityGraph(SessionFactoryScope scope) {
SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); SQLStatementInspector statementInspector = scope.getCollectingStatementInspector();
statementInspector.clear(); statementInspector.clear();
scope.inTransaction( scope.inTransaction(
@ -73,7 +73,7 @@ public class EntityGraphWithFetchAnnotationTest {
@Test @Test
@TestForIssue(jiraKey = "HHH-10485") @TestForIssue(jiraKey = "HHH-10485")
void testWithEntityGraph(SessionFactoryScope scope) { void testWithEntityGraph(SessionFactoryScope scope) {
SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); SQLStatementInspector statementInspector = scope.getCollectingStatementInspector();
statementInspector.clear(); statementInspector.clear();
scope.inTransaction( scope.inTransaction(

View File

@ -43,7 +43,7 @@ import static org.hibernate.testing.hamcrest.InitializationCheckMatcher.isNotIni
LoadAndFetchGraphTest.EEntity.class LoadAndFetchGraphTest.EEntity.class
} }
) )
@SessionFactory(statementInspectorClass = SQLStatementInspector.class) @SessionFactory(useCollectingStatementInspector = true)
@TestForIssue(jiraKey = "HHH-14097") @TestForIssue(jiraKey = "HHH-14097")
public class LoadAndFetchGraphTest { public class LoadAndFetchGraphTest {
@ -171,7 +171,7 @@ public class LoadAndFetchGraphTest {
@Test @Test
void testQueryById(SessionFactoryScope scope) { void testQueryById(SessionFactoryScope scope) {
SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); SQLStatementInspector statementInspector = scope.getCollectingStatementInspector();
statementInspector.clear(); statementInspector.clear();
scope.inTransaction( scope.inTransaction(
session -> { session -> {
@ -195,7 +195,7 @@ public class LoadAndFetchGraphTest {
@Test @Test
void testQueryByIdWithLoadGraph(SessionFactoryScope scope) { void testQueryByIdWithLoadGraph(SessionFactoryScope scope) {
SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); SQLStatementInspector statementInspector = scope.getCollectingStatementInspector();
statementInspector.clear(); statementInspector.clear();
scope.inTransaction( scope.inTransaction(
session -> { session -> {
@ -226,7 +226,7 @@ public class LoadAndFetchGraphTest {
@Test @Test
void testQueryByIdWithFetchGraph(SessionFactoryScope scope) { void testQueryByIdWithFetchGraph(SessionFactoryScope scope) {
SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); SQLStatementInspector statementInspector = scope.getCollectingStatementInspector();
statementInspector.clear(); statementInspector.clear();
scope.inTransaction( scope.inTransaction(
session -> { session -> {
@ -256,7 +256,7 @@ public class LoadAndFetchGraphTest {
@Test @Test
void testQueryByIdWithFetchGraph2(SessionFactoryScope scope) { void testQueryByIdWithFetchGraph2(SessionFactoryScope scope) {
SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); SQLStatementInspector statementInspector = scope.getCollectingStatementInspector();
statementInspector.clear(); statementInspector.clear();
scope.inTransaction( scope.inTransaction(
session -> { session -> {

View File

@ -41,7 +41,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
ElementCollectionWithSubselectFetchModeTest.Client.class ElementCollectionWithSubselectFetchModeTest.Client.class
} }
) )
@SessionFactory(statementInspectorClass = SQLStatementInspector.class) @SessionFactory(useCollectingStatementInspector = true)
@TestForIssue(jiraKey = "HHH-15640") @TestForIssue(jiraKey = "HHH-15640")
public class ElementCollectionWithSubselectFetchModeTest { public class ElementCollectionWithSubselectFetchModeTest {
@ -62,7 +62,7 @@ public class ElementCollectionWithSubselectFetchModeTest {
@Test @Test
public void testSelect(SessionFactoryScope scope) { public void testSelect(SessionFactoryScope scope) {
SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); SQLStatementInspector statementInspector = scope.getCollectingStatementInspector();
statementInspector.clear(); statementInspector.clear();
scope.inTransaction( scope.inTransaction(
session -> { session -> {

View File

@ -46,7 +46,7 @@ import static org.hamcrest.MatcherAssert.assertThat;
EagerToOneWithJoinFetchModeTests.SimpleEntity.class EagerToOneWithJoinFetchModeTests.SimpleEntity.class
} }
) )
@SessionFactory(statementInspectorClass = SQLStatementInspector.class) @SessionFactory(useCollectingStatementInspector = true)
@ServiceRegistry( @ServiceRegistry(
settings = { settings = {
@Setting(name = AvailableSettings.HBM2DDL_DATABASE_ACTION, value = "create-drop") @Setting(name = AvailableSettings.HBM2DDL_DATABASE_ACTION, value = "create-drop")
@ -79,7 +79,7 @@ public class EagerToOneWithJoinFetchModeTests {
@Test @Test
public void testFind(SessionFactoryScope scope) { public void testFind(SessionFactoryScope scope) {
SQLStatementInspector sqlStatementInterceptor = (SQLStatementInspector) scope.getStatementInspector(); SQLStatementInspector sqlStatementInterceptor = scope.getCollectingStatementInspector();
scope.inTransaction( scope.inTransaction(
session -> { session -> {
sqlStatementInterceptor.clear(); sqlStatementInterceptor.clear();
@ -103,7 +103,7 @@ public class EagerToOneWithJoinFetchModeTests {
@Test @Test
public void testHql(SessionFactoryScope scope) { public void testHql(SessionFactoryScope scope) {
SQLStatementInspector sqlStatementInterceptor = (SQLStatementInspector) scope.getStatementInspector(); SQLStatementInspector sqlStatementInterceptor = scope.getCollectingStatementInspector();
scope.inTransaction( scope.inTransaction(
session -> { session -> {
sqlStatementInterceptor.clear(); sqlStatementInterceptor.clear();
@ -133,7 +133,7 @@ public class EagerToOneWithJoinFetchModeTests {
@Test @Test
public void testHqlJoinManyToOne(SessionFactoryScope scope) { public void testHqlJoinManyToOne(SessionFactoryScope scope) {
SQLStatementInspector sqlStatementInterceptor = (SQLStatementInspector) scope.getStatementInspector(); SQLStatementInspector sqlStatementInterceptor = scope.getCollectingStatementInspector();
scope.inTransaction( scope.inTransaction(
session -> { session -> {
sqlStatementInterceptor.clear(); sqlStatementInterceptor.clear();
@ -165,7 +165,7 @@ public class EagerToOneWithJoinFetchModeTests {
@Test @Test
public void testHqlJoinOneToOne(SessionFactoryScope scope) { public void testHqlJoinOneToOne(SessionFactoryScope scope) {
SQLStatementInspector sqlStatementInterceptor = (SQLStatementInspector) scope.getStatementInspector(); SQLStatementInspector sqlStatementInterceptor = scope.getCollectingStatementInspector();
scope.inTransaction( scope.inTransaction(
session -> { session -> {
sqlStatementInterceptor.clear(); sqlStatementInterceptor.clear();
@ -198,7 +198,7 @@ public class EagerToOneWithJoinFetchModeTests {
@Test @Test
public void testHqlJoinFetchManyToOne(SessionFactoryScope scope) { public void testHqlJoinFetchManyToOne(SessionFactoryScope scope) {
SQLStatementInspector sqlStatementInterceptor = (SQLStatementInspector) scope.getStatementInspector(); SQLStatementInspector sqlStatementInterceptor = scope.getCollectingStatementInspector();
scope.inTransaction( scope.inTransaction(
session -> { session -> {
sqlStatementInterceptor.clear(); sqlStatementInterceptor.clear();
@ -228,7 +228,7 @@ public class EagerToOneWithJoinFetchModeTests {
@Test @Test
public void testHqlJoinFetchOneToOne(SessionFactoryScope scope) { public void testHqlJoinFetchOneToOne(SessionFactoryScope scope) {
SQLStatementInspector sqlStatementInterceptor = (SQLStatementInspector) scope.getStatementInspector(); SQLStatementInspector sqlStatementInterceptor = scope.getCollectingStatementInspector();
scope.inTransaction( scope.inTransaction(
session -> { session -> {
sqlStatementInterceptor.clear(); sqlStatementInterceptor.clear();
@ -258,7 +258,7 @@ public class EagerToOneWithJoinFetchModeTests {
@Test @Test
public void testHqlJoinManyToOneAndOneToOne(SessionFactoryScope scope) { public void testHqlJoinManyToOneAndOneToOne(SessionFactoryScope scope) {
SQLStatementInspector sqlStatementInterceptor = (SQLStatementInspector) scope.getStatementInspector(); SQLStatementInspector sqlStatementInterceptor = scope.getCollectingStatementInspector();
scope.inTransaction( scope.inTransaction(
session -> { session -> {
sqlStatementInterceptor.clear(); sqlStatementInterceptor.clear();

View File

@ -16,17 +16,13 @@ import jakarta.persistence.Table;
import org.hibernate.Hibernate; import org.hibernate.Hibernate;
import org.hibernate.annotations.Fetch; import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode; import org.hibernate.annotations.FetchMode;
import org.hibernate.boot.SessionFactoryBuilder;
import org.hibernate.boot.spi.MetadataImplementor;
import org.hibernate.cfg.AvailableSettings; import org.hibernate.cfg.AvailableSettings;
import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.sql.ast.SqlAstJoinType; import org.hibernate.sql.ast.SqlAstJoinType;
import org.hibernate.testing.jdbc.SQLStatementInspector; import org.hibernate.testing.jdbc.SQLStatementInspector;
import org.hibernate.testing.orm.junit.DomainModel; import org.hibernate.testing.orm.junit.DomainModel;
import org.hibernate.testing.orm.junit.ServiceRegistry; import org.hibernate.testing.orm.junit.ServiceRegistry;
import org.hibernate.testing.orm.junit.SessionFactory; 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.SessionFactoryScope;
import org.hibernate.testing.orm.junit.Setting; import org.hibernate.testing.orm.junit.Setting;
import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.AfterEach;
@ -47,7 +43,7 @@ import static org.hamcrest.MatcherAssert.assertThat;
EagerToOneWithSelectFetchModeTests.SimpleEntity.class EagerToOneWithSelectFetchModeTests.SimpleEntity.class
} }
) )
@SessionFactory(statementInspectorClass = SQLStatementInspector.class) @SessionFactory(useCollectingStatementInspector = true)
@ServiceRegistry( @ServiceRegistry(
settings = { settings = {
@Setting(name = AvailableSettings.HBM2DDL_DATABASE_ACTION, value = "create-drop") @Setting(name = AvailableSettings.HBM2DDL_DATABASE_ACTION, value = "create-drop")
@ -72,7 +68,7 @@ public class EagerToOneWithSelectFetchModeTests {
@Test @Test
public void testFind(SessionFactoryScope scope) { public void testFind(SessionFactoryScope scope) {
SQLStatementInspector sqlStatementInterceptor = (SQLStatementInspector) scope.getStatementInspector(); SQLStatementInspector sqlStatementInterceptor = scope.getCollectingStatementInspector();
scope.inTransaction( scope.inTransaction(
session -> { session -> {
sqlStatementInterceptor.clear(); sqlStatementInterceptor.clear();
@ -92,7 +88,7 @@ public class EagerToOneWithSelectFetchModeTests {
@Test @Test
public void testHql(SessionFactoryScope scope) { public void testHql(SessionFactoryScope scope) {
SQLStatementInspector sqlStatementInterceptor = (SQLStatementInspector) scope.getStatementInspector(); SQLStatementInspector sqlStatementInterceptor = scope.getCollectingStatementInspector();
scope.inTransaction( scope.inTransaction(
session -> { session -> {
sqlStatementInterceptor.clear(); sqlStatementInterceptor.clear();
@ -124,7 +120,7 @@ public class EagerToOneWithSelectFetchModeTests {
@Test @Test
public void testHqlJoinManyToOne(SessionFactoryScope scope) { public void testHqlJoinManyToOne(SessionFactoryScope scope) {
SQLStatementInspector sqlStatementInterceptor = (SQLStatementInspector) scope.getStatementInspector(); SQLStatementInspector sqlStatementInterceptor = scope.getCollectingStatementInspector();
scope.inTransaction( scope.inTransaction(
session -> { session -> {
sqlStatementInterceptor.clear(); sqlStatementInterceptor.clear();
@ -158,7 +154,7 @@ public class EagerToOneWithSelectFetchModeTests {
@Test @Test
public void testHqlJoinOneToOne(SessionFactoryScope scope) { public void testHqlJoinOneToOne(SessionFactoryScope scope) {
SQLStatementInspector sqlStatementInterceptor = (SQLStatementInspector) scope.getStatementInspector(); SQLStatementInspector sqlStatementInterceptor = scope.getCollectingStatementInspector();
scope.inTransaction( scope.inTransaction(
session -> { session -> {
sqlStatementInterceptor.clear(); sqlStatementInterceptor.clear();
@ -192,7 +188,7 @@ public class EagerToOneWithSelectFetchModeTests {
@Test @Test
public void testHqlJoinFetchManyToOne(SessionFactoryScope scope) { public void testHqlJoinFetchManyToOne(SessionFactoryScope scope) {
SQLStatementInspector sqlStatementInterceptor = (SQLStatementInspector) scope.getStatementInspector(); SQLStatementInspector sqlStatementInterceptor = scope.getCollectingStatementInspector();
scope.inTransaction( scope.inTransaction(
session -> { session -> {
sqlStatementInterceptor.clear(); sqlStatementInterceptor.clear();
@ -223,7 +219,7 @@ public class EagerToOneWithSelectFetchModeTests {
@Test @Test
public void testHqlJoinManyToOneAndOneToOne(SessionFactoryScope scope) { public void testHqlJoinManyToOneAndOneToOne(SessionFactoryScope scope) {
SQLStatementInspector sqlStatementInterceptor = (SQLStatementInspector) scope.getStatementInspector(); SQLStatementInspector sqlStatementInterceptor = scope.getCollectingStatementInspector();
scope.inTransaction( scope.inTransaction(
session -> { session -> {
sqlStatementInterceptor.clear(); sqlStatementInterceptor.clear();
@ -255,7 +251,7 @@ public class EagerToOneWithSelectFetchModeTests {
@Test @Test
public void testHqlJoinFetchOneToOne(SessionFactoryScope scope) { public void testHqlJoinFetchOneToOne(SessionFactoryScope scope) {
SQLStatementInspector sqlStatementInterceptor = (SQLStatementInspector) scope.getStatementInspector(); SQLStatementInspector sqlStatementInterceptor = scope.getCollectingStatementInspector();
scope.inTransaction( scope.inTransaction(
session -> { session -> {
sqlStatementInterceptor.clear(); sqlStatementInterceptor.clear();
@ -286,7 +282,7 @@ public class EagerToOneWithSelectFetchModeTests {
@Test @Test
public void testHqlJoinFetchManyToOneAndOneToOne(SessionFactoryScope scope) { public void testHqlJoinFetchManyToOneAndOneToOne(SessionFactoryScope scope) {
SQLStatementInspector sqlStatementInterceptor = (SQLStatementInspector) scope.getStatementInspector(); SQLStatementInspector sqlStatementInterceptor = scope.getCollectingStatementInspector();
scope.inTransaction( scope.inTransaction(
session -> { session -> {
sqlStatementInterceptor.clear(); sqlStatementInterceptor.clear();

View File

@ -44,7 +44,7 @@ import static org.hamcrest.MatcherAssert.assertThat;
LazyToOneWithJoinFetchModeTests.SimpleEntity.class LazyToOneWithJoinFetchModeTests.SimpleEntity.class
} }
) )
@SessionFactory(statementInspectorClass = SQLStatementInspector.class) @SessionFactory(useCollectingStatementInspector = true)
@ServiceRegistry( @ServiceRegistry(
settings = { settings = {
@Setting(name = AvailableSettings.HBM2DDL_DATABASE_ACTION, value = "create-drop") @Setting(name = AvailableSettings.HBM2DDL_DATABASE_ACTION, value = "create-drop")
@ -69,7 +69,7 @@ public class LazyToOneWithJoinFetchModeTests {
@Test @Test
public void testFind(SessionFactoryScope scope) { public void testFind(SessionFactoryScope scope) {
SQLStatementInspector sqlStatementInterceptor = (SQLStatementInspector) scope.getStatementInspector(); SQLStatementInspector sqlStatementInterceptor = scope.getCollectingStatementInspector();
scope.inTransaction( scope.inTransaction(
session -> { session -> {
sqlStatementInterceptor.clear(); sqlStatementInterceptor.clear();
@ -92,7 +92,7 @@ public class LazyToOneWithJoinFetchModeTests {
@Test @Test
public void testHql(SessionFactoryScope scope) { public void testHql(SessionFactoryScope scope) {
SQLStatementInspector sqlStatementInterceptor = (SQLStatementInspector) scope.getStatementInspector(); SQLStatementInspector sqlStatementInterceptor = scope.getCollectingStatementInspector();
scope.inTransaction( scope.inTransaction(
session -> { session -> {
sqlStatementInterceptor.clear(); sqlStatementInterceptor.clear();
@ -124,7 +124,7 @@ public class LazyToOneWithJoinFetchModeTests {
@Test @Test
public void testHqlJoinManyToOne(SessionFactoryScope scope) { public void testHqlJoinManyToOne(SessionFactoryScope scope) {
SQLStatementInspector sqlStatementInterceptor = (SQLStatementInspector) scope.getStatementInspector(); SQLStatementInspector sqlStatementInterceptor = scope.getCollectingStatementInspector();
scope.inTransaction( scope.inTransaction(
session -> { session -> {
sqlStatementInterceptor.clear(); sqlStatementInterceptor.clear();
@ -158,7 +158,7 @@ public class LazyToOneWithJoinFetchModeTests {
@Test @Test
public void testHqlJoinOneToOne(SessionFactoryScope scope) { public void testHqlJoinOneToOne(SessionFactoryScope scope) {
SQLStatementInspector sqlStatementInterceptor = (SQLStatementInspector) scope.getStatementInspector(); SQLStatementInspector sqlStatementInterceptor = scope.getCollectingStatementInspector();
scope.inTransaction( scope.inTransaction(
session -> { session -> {
sqlStatementInterceptor.clear(); sqlStatementInterceptor.clear();
@ -192,7 +192,7 @@ public class LazyToOneWithJoinFetchModeTests {
@Test @Test
public void testHqlJoinFetchManyToOne(SessionFactoryScope scope) { public void testHqlJoinFetchManyToOne(SessionFactoryScope scope) {
SQLStatementInspector sqlStatementInterceptor = (SQLStatementInspector) scope.getStatementInspector(); SQLStatementInspector sqlStatementInterceptor = scope.getCollectingStatementInspector();
scope.inTransaction( scope.inTransaction(
session -> { session -> {
sqlStatementInterceptor.clear(); sqlStatementInterceptor.clear();
@ -224,7 +224,7 @@ public class LazyToOneWithJoinFetchModeTests {
@Test @Test
public void testHqlJoinManyToOneAndOneToOne(SessionFactoryScope scope) { public void testHqlJoinManyToOneAndOneToOne(SessionFactoryScope scope) {
SQLStatementInspector sqlStatementInterceptor = (SQLStatementInspector) scope.getStatementInspector(); SQLStatementInspector sqlStatementInterceptor = scope.getCollectingStatementInspector();
scope.inTransaction( scope.inTransaction(
session -> { session -> {
sqlStatementInterceptor.clear(); sqlStatementInterceptor.clear();
@ -256,7 +256,7 @@ public class LazyToOneWithJoinFetchModeTests {
@Test @Test
public void testHqlJoinFetchOneToOne(SessionFactoryScope scope) { public void testHqlJoinFetchOneToOne(SessionFactoryScope scope) {
SQLStatementInspector sqlStatementInterceptor = (SQLStatementInspector) scope.getStatementInspector(); SQLStatementInspector sqlStatementInterceptor = scope.getCollectingStatementInspector();
scope.inTransaction( scope.inTransaction(
session -> { session -> {
sqlStatementInterceptor.clear(); sqlStatementInterceptor.clear();
@ -287,7 +287,7 @@ public class LazyToOneWithJoinFetchModeTests {
@Test @Test
public void testHqlJoinFetchManyToOneAndOneToOne(SessionFactoryScope scope) { public void testHqlJoinFetchManyToOneAndOneToOne(SessionFactoryScope scope) {
SQLStatementInspector sqlStatementInterceptor = (SQLStatementInspector) scope.getStatementInspector(); SQLStatementInspector sqlStatementInterceptor = scope.getCollectingStatementInspector();
scope.inTransaction( scope.inTransaction(
session -> { session -> {
sqlStatementInterceptor.clear(); sqlStatementInterceptor.clear();

View File

@ -17,18 +17,13 @@ import jakarta.persistence.Table;
import org.hibernate.Hibernate; import org.hibernate.Hibernate;
import org.hibernate.annotations.Fetch; import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode; import org.hibernate.annotations.FetchMode;
import org.hibernate.boot.SessionFactoryBuilder;
import org.hibernate.boot.spi.MetadataImplementor;
import org.hibernate.cfg.AvailableSettings; import org.hibernate.cfg.AvailableSettings;
import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.sql.ast.SqlAstJoinType; import org.hibernate.sql.ast.SqlAstJoinType;
import org.hibernate.testing.jdbc.SQLStatementInspector; 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.DomainModel;
import org.hibernate.testing.orm.junit.ServiceRegistry; import org.hibernate.testing.orm.junit.ServiceRegistry;
import org.hibernate.testing.orm.junit.SessionFactory; 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.SessionFactoryScope;
import org.hibernate.testing.orm.junit.Setting; import org.hibernate.testing.orm.junit.Setting;
import org.junit.jupiter.api.AfterEach; 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.containsString;
import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.not;
import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.MatcherAssert.assertThat;
import static org.hibernate.testing.hamcrest.CollectionMatchers.hasSize; import static org.hibernate.testing.hamcrest.CollectionMatchers.hasSize;
@ -50,7 +44,7 @@ import static org.hibernate.testing.hamcrest.CollectionMatchers.hasSize;
LazyToOneWithSelectFetchModeTests.SimpleEntity.class LazyToOneWithSelectFetchModeTests.SimpleEntity.class
} }
) )
@SessionFactory(statementInspectorClass = SQLStatementInspector.class) @SessionFactory(useCollectingStatementInspector = true)
@ServiceRegistry( @ServiceRegistry(
settings = { settings = {
@Setting(name = AvailableSettings.HBM2DDL_DATABASE_ACTION, value = "create-drop") @Setting(name = AvailableSettings.HBM2DDL_DATABASE_ACTION, value = "create-drop")
@ -75,7 +69,7 @@ public class LazyToOneWithSelectFetchModeTests {
@Test @Test
public void testFind(SessionFactoryScope scope) { public void testFind(SessionFactoryScope scope) {
SQLStatementInspector sqlStatementInterceptor = (SQLStatementInspector) scope.getStatementInspector(); SQLStatementInspector sqlStatementInterceptor = scope.getCollectingStatementInspector();
scope.inTransaction( scope.inTransaction(
session -> { session -> {
sqlStatementInterceptor.clear(); sqlStatementInterceptor.clear();
@ -93,7 +87,7 @@ public class LazyToOneWithSelectFetchModeTests {
@Test @Test
public void testHql(SessionFactoryScope scope) { public void testHql(SessionFactoryScope scope) {
SQLStatementInspector sqlStatementInterceptor = (SQLStatementInspector) scope.getStatementInspector(); SQLStatementInspector sqlStatementInterceptor = scope.getCollectingStatementInspector();
scope.inTransaction( scope.inTransaction(
session -> { session -> {
sqlStatementInterceptor.clear(); sqlStatementInterceptor.clear();
@ -115,7 +109,7 @@ public class LazyToOneWithSelectFetchModeTests {
@Test @Test
public void testHqlJoinManyToOne(SessionFactoryScope scope) { public void testHqlJoinManyToOne(SessionFactoryScope scope) {
SQLStatementInspector sqlStatementInterceptor = (SQLStatementInspector) scope.getStatementInspector(); SQLStatementInspector sqlStatementInterceptor = scope.getCollectingStatementInspector();
scope.inTransaction( scope.inTransaction(
session -> { session -> {
sqlStatementInterceptor.clear(); sqlStatementInterceptor.clear();
@ -142,7 +136,7 @@ public class LazyToOneWithSelectFetchModeTests {
@Test @Test
public void testHqlJoinOneToOne(SessionFactoryScope scope) { public void testHqlJoinOneToOne(SessionFactoryScope scope) {
SQLStatementInspector sqlStatementInterceptor = (SQLStatementInspector) scope.getStatementInspector(); SQLStatementInspector sqlStatementInterceptor = scope.getCollectingStatementInspector();
scope.inTransaction( scope.inTransaction(
session -> { session -> {
sqlStatementInterceptor.clear(); sqlStatementInterceptor.clear();
@ -170,7 +164,7 @@ public class LazyToOneWithSelectFetchModeTests {
@Test @Test
public void testHqlJoinFetchManyToOne(SessionFactoryScope scope) { public void testHqlJoinFetchManyToOne(SessionFactoryScope scope) {
SQLStatementInspector sqlStatementInterceptor = (SQLStatementInspector) scope.getStatementInspector(); SQLStatementInspector sqlStatementInterceptor = scope.getCollectingStatementInspector();
scope.inTransaction( scope.inTransaction(
session -> { session -> {
sqlStatementInterceptor.clear(); sqlStatementInterceptor.clear();
@ -197,7 +191,7 @@ public class LazyToOneWithSelectFetchModeTests {
@Test @Test
public void testHqlJoinManyToOneAndOneToOne(SessionFactoryScope scope) { public void testHqlJoinManyToOneAndOneToOne(SessionFactoryScope scope) {
SQLStatementInspector sqlStatementInterceptor = (SQLStatementInspector) scope.getStatementInspector(); SQLStatementInspector sqlStatementInterceptor = scope.getCollectingStatementInspector();
scope.inTransaction( scope.inTransaction(
session -> { session -> {
sqlStatementInterceptor.clear(); sqlStatementInterceptor.clear();
@ -224,7 +218,7 @@ public class LazyToOneWithSelectFetchModeTests {
@Test @Test
public void testHqlJoinFetchOneToOne(SessionFactoryScope scope) { public void testHqlJoinFetchOneToOne(SessionFactoryScope scope) {
SQLStatementInspector sqlStatementInterceptor = (SQLStatementInspector) scope.getStatementInspector(); SQLStatementInspector sqlStatementInterceptor = scope.getCollectingStatementInspector();
scope.inTransaction( scope.inTransaction(
session -> { session -> {
sqlStatementInterceptor.clear(); sqlStatementInterceptor.clear();
@ -251,7 +245,7 @@ public class LazyToOneWithSelectFetchModeTests {
@Test @Test
public void testHqlJoinFetchManyToOneAndOneToOne(SessionFactoryScope scope) { public void testHqlJoinFetchManyToOneAndOneToOne(SessionFactoryScope scope) {
SQLStatementInspector sqlStatementInterceptor = (SQLStatementInspector) scope.getStatementInspector(); SQLStatementInspector sqlStatementInterceptor = scope.getCollectingStatementInspector();
scope.inTransaction( scope.inTransaction(
session -> { session -> {
sqlStatementInterceptor.clear(); sqlStatementInterceptor.clear();

View File

@ -29,7 +29,7 @@ import jakarta.persistence.ManyToOne;
HHH15065Test.Person.class, HHH15065Test.Person.class,
} }
) )
@SessionFactory @SessionFactory(useCollectingStatementInspector = true)
class HHH15065Test { class HHH15065Test {
@Test @Test
@ -43,7 +43,7 @@ class HHH15065Test {
.getResultList(); .getResultList();
} ); } );
SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); SQLStatementInspector statementInspector = scope.getCollectingStatementInspector();
List<String> sqlQueries = statementInspector.getSqlQueries(); List<String> sqlQueries = statementInspector.getSqlQueries();
assertEquals( 1, sqlQueries.size() ); assertEquals( 1, sqlQueries.size() );
assertEquals( "select b1_0.id,a1_0.id,c1_0.id,c2_0.id,e1_0.id" + assertEquals( "select b1_0.id,a1_0.id,c1_0.id,c2_0.id,e1_0.id" +

View File

@ -7,8 +7,6 @@
package org.hibernate.orm.test.hql; package org.hibernate.orm.test.hql;
import java.util.Set;
import org.hibernate.query.criteria.HibernateCriteriaBuilder; import org.hibernate.query.criteria.HibernateCriteriaBuilder;
import org.hibernate.query.criteria.JpaCriteriaQuery; import org.hibernate.query.criteria.JpaCriteriaQuery;
import org.hibernate.query.criteria.JpaRoot; import org.hibernate.query.criteria.JpaRoot;
@ -36,13 +34,13 @@ import jakarta.persistence.criteria.JoinType;
ManyToOneJoinReuseTest.BookList.class ManyToOneJoinReuseTest.BookList.class
} }
) )
@SessionFactory(statementInspectorClass = SQLStatementInspector.class) @SessionFactory(useCollectingStatementInspector = true)
public class ManyToOneJoinReuseTest { public class ManyToOneJoinReuseTest {
@Test @Test
@TestForIssue(jiraKey = "HHH-15648") @TestForIssue(jiraKey = "HHH-15648")
public void fetchAndImplicitPath(SessionFactoryScope scope) { public void fetchAndImplicitPath(SessionFactoryScope scope) {
SQLStatementInspector sqlStatementInterceptor = (SQLStatementInspector) scope.getStatementInspector(); SQLStatementInspector sqlStatementInterceptor = scope.getCollectingStatementInspector();
sqlStatementInterceptor.clear(); sqlStatementInterceptor.clear();
scope.inTransaction( scope.inTransaction(
session -> { session -> {
@ -62,7 +60,7 @@ public class ManyToOneJoinReuseTest {
@Test @Test
@TestForIssue(jiraKey = "HHH-15645") @TestForIssue(jiraKey = "HHH-15645")
public void joinAndImplicitPath(SessionFactoryScope scope) { public void joinAndImplicitPath(SessionFactoryScope scope) {
SQLStatementInspector sqlStatementInterceptor = (SQLStatementInspector) scope.getStatementInspector(); SQLStatementInspector sqlStatementInterceptor = scope.getCollectingStatementInspector();
sqlStatementInterceptor.clear(); sqlStatementInterceptor.clear();
scope.inTransaction( scope.inTransaction(
session -> { session -> {

View File

@ -46,7 +46,7 @@ import static org.junit.Assert.assertFalse;
NaturalIdDereferenceTest.BookRefRef.class NaturalIdDereferenceTest.BookRefRef.class
} }
) )
@SessionFactory(statementInspectorClass = SQLStatementInspector.class) @SessionFactory(useCollectingStatementInspector = true)
public class NaturalIdDereferenceTest { public class NaturalIdDereferenceTest {
@BeforeEach @BeforeEach
@ -80,7 +80,7 @@ public class NaturalIdDereferenceTest {
@Test @Test
public void naturalIdDereferenceTest(SessionFactoryScope scope) { public void naturalIdDereferenceTest(SessionFactoryScope scope) {
SQLStatementInspector sqlStatementInterceptor = (SQLStatementInspector) scope.getStatementInspector(); SQLStatementInspector sqlStatementInterceptor = scope.getCollectingStatementInspector();
sqlStatementInterceptor.clear(); sqlStatementInterceptor.clear();
scope.inTransaction( scope.inTransaction(
session -> { session -> {
@ -95,7 +95,7 @@ public class NaturalIdDereferenceTest {
@Test @Test
public void normalIdDereferenceFromAlias(SessionFactoryScope scope) { public void normalIdDereferenceFromAlias(SessionFactoryScope scope) {
SQLStatementInspector sqlStatementInterceptor = (SQLStatementInspector) scope.getStatementInspector(); SQLStatementInspector sqlStatementInterceptor = scope.getCollectingStatementInspector();
sqlStatementInterceptor.clear(); sqlStatementInterceptor.clear();
scope.inTransaction( scope.inTransaction(
session -> { session -> {
@ -110,7 +110,7 @@ public class NaturalIdDereferenceTest {
@Test @Test
public void naturalIdDereferenceFromAlias(SessionFactoryScope scope) { public void naturalIdDereferenceFromAlias(SessionFactoryScope scope) {
SQLStatementInspector sqlStatementInterceptor = (SQLStatementInspector) scope.getStatementInspector(); SQLStatementInspector sqlStatementInterceptor = scope.getCollectingStatementInspector();
sqlStatementInterceptor.clear(); sqlStatementInterceptor.clear();
scope.inTransaction( scope.inTransaction(
session -> { session -> {
@ -125,7 +125,7 @@ public class NaturalIdDereferenceTest {
@Test @Test
public void normalIdDereferenceFromImplicitJoin(SessionFactoryScope scope) { public void normalIdDereferenceFromImplicitJoin(SessionFactoryScope scope) {
SQLStatementInspector sqlStatementInterceptor = (SQLStatementInspector) scope.getStatementInspector(); SQLStatementInspector sqlStatementInterceptor = scope.getCollectingStatementInspector();
sqlStatementInterceptor.clear(); sqlStatementInterceptor.clear();
scope.inTransaction( scope.inTransaction(
session -> { session -> {
@ -139,7 +139,7 @@ public class NaturalIdDereferenceTest {
@Test @Test
public void naturalIdDereferenceFromImplicitJoin(SessionFactoryScope scope) { public void naturalIdDereferenceFromImplicitJoin(SessionFactoryScope scope) {
SQLStatementInspector sqlStatementInterceptor = (SQLStatementInspector) scope.getStatementInspector(); SQLStatementInspector sqlStatementInterceptor = scope.getCollectingStatementInspector();
sqlStatementInterceptor.clear(); sqlStatementInterceptor.clear();
scope.inTransaction( scope.inTransaction(
session -> { session -> {
@ -158,7 +158,7 @@ public class NaturalIdDereferenceTest {
*/ */
@Test @Test
public void nestedNaturalIdDereferenceFromImplicitJoin(SessionFactoryScope scope) { public void nestedNaturalIdDereferenceFromImplicitJoin(SessionFactoryScope scope) {
SQLStatementInspector sqlStatementInterceptor = (SQLStatementInspector) scope.getStatementInspector(); SQLStatementInspector sqlStatementInterceptor = scope.getCollectingStatementInspector();
sqlStatementInterceptor.clear(); sqlStatementInterceptor.clear();
scope.inTransaction( scope.inTransaction(
session -> { session -> {
@ -176,7 +176,7 @@ public class NaturalIdDereferenceTest {
*/ */
@Test @Test
public void nestedNaturalIdDereferenceFromImplicitJoin2(SessionFactoryScope scope) { public void nestedNaturalIdDereferenceFromImplicitJoin2(SessionFactoryScope scope) {
SQLStatementInspector sqlStatementInterceptor = (SQLStatementInspector) scope.getStatementInspector(); SQLStatementInspector sqlStatementInterceptor = scope.getCollectingStatementInspector();
sqlStatementInterceptor.clear(); sqlStatementInterceptor.clear();
scope.inTransaction( scope.inTransaction(
session -> { session -> {
@ -190,7 +190,7 @@ public class NaturalIdDereferenceTest {
@Test @Test
public void doNotDereferenceNaturalIdIfIsReferenceToPrimaryKey(SessionFactoryScope scope) { public void doNotDereferenceNaturalIdIfIsReferenceToPrimaryKey(SessionFactoryScope scope) {
SQLStatementInspector sqlStatementInterceptor = (SQLStatementInspector) scope.getStatementInspector(); SQLStatementInspector sqlStatementInterceptor = scope.getCollectingStatementInspector();
sqlStatementInterceptor.clear(); sqlStatementInterceptor.clear();
scope.inTransaction( scope.inTransaction(
session -> { session -> {
@ -204,7 +204,7 @@ public class NaturalIdDereferenceTest {
@Test @Test
public void selectedEntityIsNotDereferencedForPrimaryKey(SessionFactoryScope scope) { public void selectedEntityIsNotDereferencedForPrimaryKey(SessionFactoryScope scope) {
SQLStatementInspector sqlStatementInterceptor = (SQLStatementInspector) scope.getStatementInspector(); SQLStatementInspector sqlStatementInterceptor = scope.getCollectingStatementInspector();
sqlStatementInterceptor.clear(); sqlStatementInterceptor.clear();
scope.inTransaction( scope.inTransaction(
session -> { session -> {
@ -229,7 +229,7 @@ public class NaturalIdDereferenceTest {
*/ */
@Test @Test
public void selectedEntityIsNotDereferencedForNaturalId(SessionFactoryScope scope) { public void selectedEntityIsNotDereferencedForNaturalId(SessionFactoryScope scope) {
SQLStatementInspector sqlStatementInterceptor = (SQLStatementInspector) scope.getStatementInspector(); SQLStatementInspector sqlStatementInterceptor = scope.getCollectingStatementInspector();
sqlStatementInterceptor.clear(); sqlStatementInterceptor.clear();
scope.inTransaction( scope.inTransaction(
session -> { session -> {
@ -249,7 +249,7 @@ public class NaturalIdDereferenceTest {
*/ */
@Test @Test
public void dereferenceNaturalIdInJoin(SessionFactoryScope scope) { public void dereferenceNaturalIdInJoin(SessionFactoryScope scope) {
SQLStatementInspector sqlStatementInterceptor = (SQLStatementInspector) scope.getStatementInspector(); SQLStatementInspector sqlStatementInterceptor = scope.getCollectingStatementInspector();
sqlStatementInterceptor.clear(); sqlStatementInterceptor.clear();
scope.inTransaction( scope.inTransaction(
session -> { session -> {
@ -273,7 +273,7 @@ public class NaturalIdDereferenceTest {
*/ */
@Test @Test
public void dereferenceNaturalIdInJoin2(SessionFactoryScope scope) { public void dereferenceNaturalIdInJoin2(SessionFactoryScope scope) {
SQLStatementInspector sqlStatementInterceptor = (SQLStatementInspector) scope.getStatementInspector(); SQLStatementInspector sqlStatementInterceptor = scope.getCollectingStatementInspector();
sqlStatementInterceptor.clear(); sqlStatementInterceptor.clear();
scope.inTransaction( scope.inTransaction(
session -> { session -> {
@ -294,7 +294,7 @@ public class NaturalIdDereferenceTest {
*/ */
@Test @Test
public void dereferenceNaturalIdInJoin3(SessionFactoryScope scope) { public void dereferenceNaturalIdInJoin3(SessionFactoryScope scope) {
SQLStatementInspector sqlStatementInterceptor = (SQLStatementInspector) scope.getStatementInspector(); SQLStatementInspector sqlStatementInterceptor = scope.getCollectingStatementInspector();
sqlStatementInterceptor.clear(); sqlStatementInterceptor.clear();
scope.inTransaction( scope.inTransaction(
session -> { session -> {
@ -316,7 +316,7 @@ public class NaturalIdDereferenceTest {
*/ */
@Test @Test
public void dereferenceNaturalIdInJoin4(SessionFactoryScope scope) { public void dereferenceNaturalIdInJoin4(SessionFactoryScope scope) {
SQLStatementInspector sqlStatementInterceptor = (SQLStatementInspector) scope.getStatementInspector(); SQLStatementInspector sqlStatementInterceptor = scope.getCollectingStatementInspector();
sqlStatementInterceptor.clear(); sqlStatementInterceptor.clear();
scope.inTransaction( scope.inTransaction(
session -> { session -> {

View File

@ -6,7 +6,6 @@
*/ */
package org.hibernate.orm.test.id; package org.hibernate.orm.test.id;
import org.hibernate.cfg.Environment;
import org.hibernate.dialect.SQLServerDialect; import org.hibernate.dialect.SQLServerDialect;
import org.hibernate.testing.TestForIssue; 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.DialectFeatureChecks;
import org.hibernate.testing.orm.junit.DomainModel; import org.hibernate.testing.orm.junit.DomainModel;
import org.hibernate.testing.orm.junit.RequiresDialectFeature; 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.SessionFactory;
import org.hibernate.testing.orm.junit.SessionFactoryScope; import org.hibernate.testing.orm.junit.SessionFactoryScope;
import org.hibernate.testing.orm.junit.Setting;
import org.hibernate.testing.orm.junit.SkipForDialect; import org.hibernate.testing.orm.junit.SkipForDialect;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
@ -26,7 +23,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
@DomainModel( @DomainModel(
xmlMappings = "org/hibernate/orm/test/id/Person.hbm.xml" xmlMappings = "org/hibernate/orm/test/id/Person.hbm.xml"
) )
@SessionFactory(statementInspectorClass = SQLStatementInspector.class) @SessionFactory(useCollectingStatementInspector = true)
public class SequenceGeneratorTest { public class SequenceGeneratorTest {
@ -51,7 +48,7 @@ public class SequenceGeneratorTest {
); );
assertTrue( person.getId() > 0 ); assertTrue( person.getId() > 0 );
final SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); final SQLStatementInspector statementInspector = scope.getCollectingStatementInspector();
assertTrue( statementInspector.getSqlQueries() assertTrue( statementInspector.getSqlQueries()
.stream() .stream()
.filter( sql -> sql.contains( "product_sequence" ) ) .filter( sql -> sql.contains( "product_sequence" ) )

View File

@ -29,7 +29,7 @@ import static org.hamcrest.MatcherAssert.assertThat;
@DomainModel( @DomainModel(
annotatedClasses = { IdClassTest.SystemUser.class } annotatedClasses = { IdClassTest.SystemUser.class }
) )
@SessionFactory(statementInspectorClass = SQLStatementInspector.class) @SessionFactory(useCollectingStatementInspector = true)
public class IdClassTest { public class IdClassTest {
@BeforeEach @BeforeEach
@ -55,7 +55,7 @@ public class IdClassTest {
@Test @Test
public void testGet(SessionFactoryScope scope) { public void testGet(SessionFactoryScope scope) {
SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); SQLStatementInspector statementInspector = scope.getCollectingStatementInspector();
statementInspector.clear(); statementInspector.clear();
scope.inTransaction( scope.inTransaction(
session -> { session -> {
@ -78,7 +78,7 @@ public class IdClassTest {
@Test @Test
public void testHql(SessionFactoryScope scope) { public void testHql(SessionFactoryScope scope) {
SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); SQLStatementInspector statementInspector = scope.getCollectingStatementInspector();
statementInspector.clear(); statementInspector.clear();
scope.inTransaction( scope.inTransaction(
session -> { session -> {

View File

@ -35,7 +35,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
IdClassWithEagerManyToOneTest.Subsystem.class IdClassWithEagerManyToOneTest.Subsystem.class
} }
) )
@SessionFactory(statementInspectorClass = SQLStatementInspector.class) @SessionFactory(useCollectingStatementInspector = true)
public class IdClassWithEagerManyToOneTest { public class IdClassWithEagerManyToOneTest {
@BeforeEach @BeforeEach
@ -63,7 +63,7 @@ public class IdClassWithEagerManyToOneTest {
@Test @Test
public void testGet(SessionFactoryScope scope) { public void testGet(SessionFactoryScope scope) {
SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); SQLStatementInspector statementInspector = scope.getCollectingStatementInspector();
statementInspector.clear(); statementInspector.clear();
scope.inTransaction( scope.inTransaction(
session -> { session -> {
@ -92,7 +92,7 @@ public class IdClassWithEagerManyToOneTest {
@Test @Test
public void testHql(SessionFactoryScope scope) { public void testHql(SessionFactoryScope scope) {
SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); SQLStatementInspector statementInspector = scope.getCollectingStatementInspector();
statementInspector.clear(); statementInspector.clear();
scope.inTransaction( scope.inTransaction(
session -> { session -> {
@ -166,7 +166,7 @@ public class IdClassWithEagerManyToOneTest {
@Test @Test
public void testHql2(SessionFactoryScope scope) { public void testHql2(SessionFactoryScope scope) {
SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); SQLStatementInspector statementInspector = scope.getCollectingStatementInspector();
statementInspector.clear(); statementInspector.clear();
scope.inTransaction( scope.inTransaction(
session -> { session -> {

View File

@ -37,7 +37,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
IdClassWithLazyManyToOneTest.Subsystem.class IdClassWithLazyManyToOneTest.Subsystem.class
} }
) )
@SessionFactory(statementInspectorClass = SQLStatementInspector.class) @SessionFactory(useCollectingStatementInspector = true)
public class IdClassWithLazyManyToOneTest { public class IdClassWithLazyManyToOneTest {
@BeforeEach @BeforeEach
@ -65,7 +65,7 @@ public class IdClassWithLazyManyToOneTest {
@Test @Test
public void testGet(SessionFactoryScope scope) { public void testGet(SessionFactoryScope scope) {
SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); SQLStatementInspector statementInspector = scope.getCollectingStatementInspector();
statementInspector.clear(); statementInspector.clear();
scope.inTransaction( scope.inTransaction(
session -> { session -> {
@ -102,7 +102,7 @@ public class IdClassWithLazyManyToOneTest {
@Test @Test
public void testHql(SessionFactoryScope scope) { public void testHql(SessionFactoryScope scope) {
SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); SQLStatementInspector statementInspector = scope.getCollectingStatementInspector();
statementInspector.clear(); statementInspector.clear();
scope.inTransaction( scope.inTransaction(
session -> { session -> {
@ -177,7 +177,7 @@ public class IdClassWithLazyManyToOneTest {
@Test @Test
public void testHql2(SessionFactoryScope scope) { public void testHql2(SessionFactoryScope scope) {
SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); SQLStatementInspector statementInspector = scope.getCollectingStatementInspector();
statementInspector.clear(); statementInspector.clear();
scope.inTransaction( scope.inTransaction(
session -> { session -> {

View File

@ -2,13 +2,9 @@ package org.hibernate.orm.test.jpa.association.toone;
import java.util.List; import java.util.List;
import org.hibernate.cfg.AvailableSettings;
import org.hibernate.testing.jdbc.SQLStatementInspector; 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.EntityManagerFactoryScope;
import org.hibernate.testing.orm.junit.Jpa; 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.AfterEach;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
@ -38,13 +34,7 @@ import static org.hamcrest.MatcherAssert.assertThat;
CriteriaJoinFetchTest.Address.class, CriteriaJoinFetchTest.Address.class,
CriteriaJoinFetchTest.Note.class CriteriaJoinFetchTest.Note.class
}, },
settingProviders = { useCollectingStatementInspector = true
@SettingProvider(
settingName = AvailableSettings.STATEMENT_INSPECTOR,
provider = DefaultSQLStatementInspectorSettingProvider.class
)
}
) )
public class CriteriaJoinFetchTest { public class CriteriaJoinFetchTest {
@ -52,7 +42,7 @@ public class CriteriaJoinFetchTest {
@BeforeEach @BeforeEach
public void setUp(EntityManagerFactoryScope scope) { public void setUp(EntityManagerFactoryScope scope) {
statementInspector = scope.getStatementInspector( SQLStatementInspector.class ); statementInspector = scope.getCollectingStatementInspector();
scope.inTransaction( scope.inTransaction(
entityManager -> { entityManager -> {

View File

@ -24,7 +24,7 @@ import org.junit.jupiter.api.Test;
annotatedClasses = { annotatedClasses = {
MapOwner.class, MapContent.class, Relationship.class MapOwner.class, MapContent.class, Relationship.class
}) })
@SessionFactory(statementInspectorClass = SQLStatementInspector.class) @SessionFactory(useCollectingStatementInspector = true)
public class MapIssueTest { public class MapIssueTest {
@Test @Test
@ -39,7 +39,7 @@ public class MapIssueTest {
@Test @Test
public void testOnlyCollectionTableJoined(SessionFactoryScope scope) { public void testOnlyCollectionTableJoined(SessionFactoryScope scope) {
SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); SQLStatementInspector statementInspector = scope.getCollectingStatementInspector();
statementInspector.clear(); statementInspector.clear();
scope.inTransaction( scope.inTransaction(
s -> { s -> {
@ -53,7 +53,7 @@ public class MapIssueTest {
@Test @Test
public void testMapKeyJoinIsOmitted(SessionFactoryScope scope) { public void testMapKeyJoinIsOmitted(SessionFactoryScope scope) {
SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); SQLStatementInspector statementInspector = scope.getCollectingStatementInspector();
statementInspector.clear(); statementInspector.clear();
scope.inTransaction( scope.inTransaction(
s -> { s -> {
@ -67,7 +67,7 @@ public class MapIssueTest {
@Test @Test
public void testMapKeyJoinIsReused(SessionFactoryScope scope) { public void testMapKeyJoinIsReused(SessionFactoryScope scope) {
SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); SQLStatementInspector statementInspector = scope.getCollectingStatementInspector();
statementInspector.clear(); statementInspector.clear();
scope.inTransaction( scope.inTransaction(
s -> { s -> {
@ -81,7 +81,7 @@ public class MapIssueTest {
@Test @Test
public void testMapKeyJoinIsReusedForFurtherJoin(SessionFactoryScope scope) { public void testMapKeyJoinIsReusedForFurtherJoin(SessionFactoryScope scope) {
SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); SQLStatementInspector statementInspector = scope.getCollectingStatementInspector();
statementInspector.clear(); statementInspector.clear();
scope.inTransaction( scope.inTransaction(
s -> { s -> {
@ -95,7 +95,7 @@ public class MapIssueTest {
@Test @Test
public void testMapKeyJoinIsReusedForFurtherJoinAndElementJoinIsProperlyOrdered(SessionFactoryScope scope) { public void testMapKeyJoinIsReusedForFurtherJoinAndElementJoinIsProperlyOrdered(SessionFactoryScope scope) {
SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); SQLStatementInspector statementInspector = scope.getCollectingStatementInspector();
statementInspector.clear(); statementInspector.clear();
scope.inTransaction( scope.inTransaction(
s -> { s -> {
@ -110,7 +110,7 @@ public class MapIssueTest {
@Test @Test
@TestForIssue( jiraKey = "HHH-15357") @TestForIssue( jiraKey = "HHH-15357")
public void testSelectMapKeyFk(SessionFactoryScope scope) { public void testSelectMapKeyFk(SessionFactoryScope scope) {
SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); SQLStatementInspector statementInspector = scope.getCollectingStatementInspector();
statementInspector.clear(); statementInspector.clear();
scope.inTransaction( scope.inTransaction(
s -> { s -> {

View File

@ -24,12 +24,10 @@ import org.hibernate.dialect.OracleDialect;
import org.hibernate.testing.TestForIssue; import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.jdbc.SQLStatementInspector; 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.EntityManagerFactoryScope;
import org.hibernate.testing.orm.junit.Jpa; import org.hibernate.testing.orm.junit.Jpa;
import org.hibernate.testing.orm.junit.RequiresDialect; import org.hibernate.testing.orm.junit.RequiresDialect;
import org.hibernate.testing.orm.junit.Setting; 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.AfterAll;
import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeAll;
@ -45,12 +43,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
integrationSettings = { integrationSettings = {
@Setting( name = AvailableSettings.USE_SQL_COMMENTS, value = "true" ) @Setting( name = AvailableSettings.USE_SQL_COMMENTS, value = "true" )
}, },
settingProviders = { useCollectingStatementInspector = true
@SettingProvider(
settingName = AvailableSettings.STATEMENT_INSPECTOR,
provider = DefaultSQLStatementInspectorSettingProvider.class
)
}
) )
@TestForIssue(jiraKey = "HHH-11640") @TestForIssue(jiraKey = "HHH-11640")
public class NamedQueryCommentTest { public class NamedQueryCommentTest {
@ -62,7 +55,7 @@ public class NamedQueryCommentTest {
@BeforeAll @BeforeAll
public void setUp(EntityManagerFactoryScope scope) { public void setUp(EntityManagerFactoryScope scope) {
statementInspector = scope.getStatementInspector( SQLStatementInspector.class ); statementInspector = scope.getCollectingStatementInspector();
scope.inTransaction( scope.inTransaction(
entityManager -> { entityManager -> {

View File

@ -38,7 +38,7 @@ import static org.assertj.core.api.Assertions.assertThat;
SimpleEagerSubSelectFetchTests.Owner.class, SimpleEagerSubSelectFetchTests.Owner.class,
SimpleEagerSubSelectFetchTests.Thing.class SimpleEagerSubSelectFetchTests.Thing.class
}) })
@SessionFactory( statementInspectorClass = SQLStatementInspector.class ) @SessionFactory( useCollectingStatementInspector = true )
public class SimpleEagerSubSelectFetchTests { public class SimpleEagerSubSelectFetchTests {
@Test @Test

View File

@ -38,12 +38,12 @@ import static org.assertj.core.api.Assertions.assertThat;
SimpleLazySubSelectFetchTests.Owner.class, SimpleLazySubSelectFetchTests.Owner.class,
SimpleLazySubSelectFetchTests.Thing.class SimpleLazySubSelectFetchTests.Thing.class
}) })
@SessionFactory( statementInspectorClass = SQLStatementInspector.class ) @SessionFactory( useCollectingStatementInspector = true )
public class SimpleLazySubSelectFetchTests { public class SimpleLazySubSelectFetchTests {
@Test @Test
public void smokeTest(SessionFactoryScope scope) { public void smokeTest(SessionFactoryScope scope) {
final SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); final SQLStatementInspector statementInspector = scope.getCollectingStatementInspector();
statementInspector.clear(); statementInspector.clear();
scope.inTransaction( (session) -> { scope.inTransaction( (session) -> {
@ -93,7 +93,7 @@ public class SimpleLazySubSelectFetchTests {
@Test @Test
public void baselineJoinFetchTest(SessionFactoryScope scope) { public void baselineJoinFetchTest(SessionFactoryScope scope) {
final SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); final SQLStatementInspector statementInspector = scope.getCollectingStatementInspector();
statementInspector.clear(); statementInspector.clear();
scope.inTransaction( (session) -> { scope.inTransaction( (session) -> {

View File

@ -44,7 +44,7 @@ import static org.assertj.core.api.Assertions.assertThat;
SimpleMultipleEagerSubSelectFetchTests.Thing.class, SimpleMultipleEagerSubSelectFetchTests.Thing.class,
SimpleMultipleEagerSubSelectFetchTests.Trinket.class, SimpleMultipleEagerSubSelectFetchTests.Trinket.class,
}) })
@SessionFactory( statementInspectorClass = SQLStatementInspector.class ) @SessionFactory( useCollectingStatementInspector = true )
public class SimpleMultipleEagerSubSelectFetchTests { public class SimpleMultipleEagerSubSelectFetchTests {
@Test @Test

View File

@ -44,12 +44,12 @@ import static org.assertj.core.api.Assertions.assertThat;
SimpleMultipleLazySubSelectFetchTests.Thing.class, SimpleMultipleLazySubSelectFetchTests.Thing.class,
SimpleMultipleLazySubSelectFetchTests.Trinket.class, SimpleMultipleLazySubSelectFetchTests.Trinket.class,
}) })
@SessionFactory( statementInspectorClass = SQLStatementInspector.class ) @SessionFactory( useCollectingStatementInspector = true )
public class SimpleMultipleLazySubSelectFetchTests { public class SimpleMultipleLazySubSelectFetchTests {
@Test @Test
public void smokeTest(SessionFactoryScope scope) { public void smokeTest(SessionFactoryScope scope) {
final SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); final SQLStatementInspector statementInspector = scope.getCollectingStatementInspector();
statementInspector.clear(); statementInspector.clear();
scope.inTransaction( (session) -> { scope.inTransaction( (session) -> {

View File

@ -94,7 +94,7 @@ public class SubselectFetchCollectionFromBatchTest {
return new EmployeeGroup[] { group1, group2 }; return new EmployeeGroup[] { group1, group2 };
}); });
final SQLStatementInspector statementInspector = scope.getStatementInspector( SQLStatementInspector.class ); final SQLStatementInspector statementInspector = scope.getCollectingStatementInspector();
statementInspector.clear(); statementInspector.clear();
scope.inTransaction( (s) -> { scope.inTransaction( (s) -> {

View File

@ -28,9 +28,9 @@ import jakarta.persistence.criteria.JoinType;
import jakarta.persistence.criteria.Root; import jakarta.persistence.criteria.Root;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertEquals; import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.Assert.assertFalse; import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.Assert.assertTrue; import static org.junit.jupiter.api.Assertions.assertTrue;
/** /**
* @author Gavin King * @author Gavin King
@ -305,7 +305,7 @@ public class SubselectFetchTest {
@Test @Test
public void testSubselectFetchCriteria(SessionFactoryScope scope) { public void testSubselectFetchCriteria(SessionFactoryScope scope) {
final SQLStatementInspector statementInspector = scope.getStatementInspector( SQLStatementInspector.class ); final SQLStatementInspector statementInspector = scope.getCollectingStatementInspector();
statementInspector.clear(); statementInspector.clear();
scope.inTransaction( scope.inTransaction(

View File

@ -80,7 +80,7 @@ import jakarta.persistence.OrderColumn;
MultiInheritanceImplicitDowncastTest.PolymorphicSub1.class, MultiInheritanceImplicitDowncastTest.PolymorphicSub1.class,
MultiInheritanceImplicitDowncastTest.PolymorphicSub2.class MultiInheritanceImplicitDowncastTest.PolymorphicSub2.class
}) })
@SessionFactory(statementInspectorClass = SQLStatementInspector.class) @SessionFactory(useCollectingStatementInspector = true)
public class MultiInheritanceImplicitDowncastTest { public class MultiInheritanceImplicitDowncastTest {
@Test @Test
@ -117,7 +117,7 @@ public class MultiInheritanceImplicitDowncastTest {
} }
private void testMultiJoinAddition(SessionFactoryScope scope, String joinColumnBase, String hql) { private void testMultiJoinAddition(SessionFactoryScope scope, String joinColumnBase, String hql) {
SQLStatementInspector sqlStatementInterceptor = (SQLStatementInspector) scope.getStatementInspector(); SQLStatementInspector sqlStatementInterceptor = scope.getCollectingStatementInspector();
scope.inTransaction( scope.inTransaction(
s -> { s -> {
sqlStatementInterceptor.clear(); sqlStatementInterceptor.clear();

View File

@ -31,7 +31,7 @@ import static org.hibernate.orm.test.mapping.manytoone.ManyToOneBidirectionalCir
EntityTest2.class EntityTest2.class
} }
) )
@SessionFactory(statementInspectorClass = SQLStatementInspector.class) @SessionFactory(useCollectingStatementInspector = true)
public class ManyToOneBidirectionalCircularityTest { public class ManyToOneBidirectionalCircularityTest {
@BeforeEach @BeforeEach
@ -50,7 +50,7 @@ public class ManyToOneBidirectionalCircularityTest {
@Test @Test
public void testGet(SessionFactoryScope scope) { public void testGet(SessionFactoryScope scope) {
SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); SQLStatementInspector statementInspector = scope.getCollectingStatementInspector();
statementInspector.clear(); statementInspector.clear();
scope.inTransaction( scope.inTransaction(
session -> { session -> {

View File

@ -25,7 +25,7 @@ import static org.hibernate.orm.test.mapping.manytoone.ManyToOneBidirectionalTes
* @author Andrea Boriero * @author Andrea Boriero
*/ */
@DomainModel( annotatedClasses = { EntityTest.class, EntityTest2.class } ) @DomainModel( annotatedClasses = { EntityTest.class, EntityTest2.class } )
@SessionFactory(statementInspectorClass = SQLStatementInspector.class) @SessionFactory(useCollectingStatementInspector = true)
public class ManyToOneBidirectionalTest { public class ManyToOneBidirectionalTest {
@BeforeEach @BeforeEach
@ -46,7 +46,7 @@ public class ManyToOneBidirectionalTest {
@Test @Test
public void testGet(SessionFactoryScope scope) { public void testGet(SessionFactoryScope scope) {
SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); SQLStatementInspector statementInspector = scope.getCollectingStatementInspector();
statementInspector.clear(); statementInspector.clear();
scope.inTransaction( scope.inTransaction(
session -> { session -> {

View File

@ -22,7 +22,6 @@ import org.hibernate.stat.Statistics;
import org.hibernate.testing.jdbc.SQLStatementInspector; import org.hibernate.testing.jdbc.SQLStatementInspector;
import org.hibernate.testing.orm.junit.DomainModel; 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.ServiceRegistry;
import org.hibernate.testing.orm.junit.SessionFactory; import org.hibernate.testing.orm.junit.SessionFactory;
import org.hibernate.testing.orm.junit.SessionFactoryScope; import org.hibernate.testing.orm.junit.SessionFactoryScope;
@ -48,7 +47,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
OneToManyBidirectionalTest.Item.class OneToManyBidirectionalTest.Item.class
} }
) )
@SessionFactory(statementInspectorClass = SQLStatementInspector.class) @SessionFactory(useCollectingStatementInspector = true)
@ServiceRegistry( @ServiceRegistry(
settings = { settings = {
@Setting(name = AvailableSettings.GENERATE_STATISTICS, value = "true"), @Setting(name = AvailableSettings.GENERATE_STATISTICS, value = "true"),
@ -84,7 +83,7 @@ public class OneToManyBidirectionalTest {
@Test @Test
public void testFetchingSameAssociationTwice(SessionFactoryScope scope) { public void testFetchingSameAssociationTwice(SessionFactoryScope scope) {
SQLStatementInspector sqlStatementInterceptor = (SQLStatementInspector) scope.getStatementInspector(); SQLStatementInspector sqlStatementInterceptor = scope.getCollectingStatementInspector();
scope.inTransaction( scope.inTransaction(
session -> { session -> {
Statistics statistics = session.getSessionFactory().getStatistics(); Statistics statistics = session.getSessionFactory().getStatistics();
@ -135,7 +134,7 @@ public class OneToManyBidirectionalTest {
@Test @Test
public void testRetrievingItem(SessionFactoryScope scope) { public void testRetrievingItem(SessionFactoryScope scope) {
SQLStatementInspector sqlStatementInterceptor = (SQLStatementInspector) scope.getStatementInspector(); SQLStatementInspector sqlStatementInterceptor = scope.getCollectingStatementInspector();
scope.inTransaction( scope.inTransaction(
session -> { session -> {
Statistics statistics = session.getSessionFactory().getStatistics(); Statistics statistics = session.getSessionFactory().getStatistics();
@ -356,7 +355,7 @@ public class OneToManyBidirectionalTest {
@Test @Test
public void testRetrievingOrder(SessionFactoryScope scope) { public void testRetrievingOrder(SessionFactoryScope scope) {
SQLStatementInspector sqlStatementInterceptor = (SQLStatementInspector) scope.getStatementInspector(); SQLStatementInspector sqlStatementInterceptor = scope.getCollectingStatementInspector();
scope.inTransaction( session -> { scope.inTransaction( session -> {
Statistics statistics = session.getSessionFactory().getStatistics(); Statistics statistics = session.getSessionFactory().getStatistics();
statistics.clear(); statistics.clear();
@ -591,7 +590,7 @@ public class OneToManyBidirectionalTest {
@Test @Test
public void testItemFetchJoin(SessionFactoryScope scope) { public void testItemFetchJoin(SessionFactoryScope scope) {
SQLStatementInspector sqlStatementInterceptor = (SQLStatementInspector) scope.getStatementInspector(); SQLStatementInspector sqlStatementInterceptor = scope.getCollectingStatementInspector();
scope.inTransaction( session -> { scope.inTransaction( session -> {
Statistics statistics = session.getSessionFactory().getStatistics(); Statistics statistics = session.getSessionFactory().getStatistics();
statistics.clear(); statistics.clear();
@ -624,7 +623,7 @@ public class OneToManyBidirectionalTest {
@Test @Test
public void testItemJoinWithFetchJoin(SessionFactoryScope scope) { public void testItemJoinWithFetchJoin(SessionFactoryScope scope) {
SQLStatementInspector sqlStatementInterceptor = (SQLStatementInspector) scope.getStatementInspector(); SQLStatementInspector sqlStatementInterceptor = scope.getCollectingStatementInspector();
Assertions.assertThrows( IllegalArgumentException.class, () -> Assertions.assertThrows( IllegalArgumentException.class, () ->
scope.inTransaction( session -> { scope.inTransaction( session -> {
Statistics statistics = session.getSessionFactory().getStatistics(); Statistics statistics = session.getSessionFactory().getStatistics();

View File

@ -43,7 +43,7 @@ import static org.junit.jupiter.api.Assertions.fail;
Key.class Key.class
} }
) )
@SessionFactory(statementInspectorClass = SQLStatementInspector.class) @SessionFactory(useCollectingStatementInspector = true)
public class OneToManyTest { public class OneToManyTest {
public static final String CARD_ID = "cardId"; public static final String CARD_ID = "cardId";
public static final String CARD_FIELD_ID = "cardFieldId"; public static final String CARD_FIELD_ID = "cardFieldId";
@ -81,7 +81,7 @@ public class OneToManyTest {
@Test @Test
public void testGet(SessionFactoryScope scope) { public void testGet(SessionFactoryScope scope) {
SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); SQLStatementInspector statementInspector = scope.getCollectingStatementInspector();
statementInspector.clear(); statementInspector.clear();
scope.inTransaction( scope.inTransaction(
session -> { session -> {

View File

@ -13,13 +13,9 @@ import jakarta.persistence.JoinColumn;
import jakarta.persistence.MapsId; import jakarta.persistence.MapsId;
import jakarta.persistence.OneToOne; 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.jdbc.SQLStatementInspector;
import org.hibernate.testing.orm.junit.EntityManagerFactoryScope; import org.hibernate.testing.orm.junit.EntityManagerFactoryScope;
import org.hibernate.testing.orm.junit.Jpa; 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.BeforeEach;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
@ -33,12 +29,7 @@ import static org.junit.jupiter.api.Assertions.assertSame;
OneToOneMapsIdJoinColumnTest.Person.class, OneToOneMapsIdJoinColumnTest.Person.class,
OneToOneMapsIdJoinColumnTest.PersonDetails.class OneToOneMapsIdJoinColumnTest.PersonDetails.class
}, },
settingProviders = { useCollectingStatementInspector = true
@SettingProvider(
settingName = AvailableSettings.STATEMENT_INSPECTOR,
provider = DefaultSQLStatementInspectorSettingProvider.class
)
}
) )
public class OneToOneMapsIdJoinColumnTest { public class OneToOneMapsIdJoinColumnTest {
@ -59,7 +50,7 @@ public class OneToOneMapsIdJoinColumnTest {
@Test @Test
public void testLifecycle(EntityManagerFactoryScope scope) { public void testLifecycle(EntityManagerFactoryScope scope) {
SQLStatementInspector statementInspector = scope.getStatementInspector( SQLStatementInspector.class ); SQLStatementInspector statementInspector = scope.getCollectingStatementInspector();
statementInspector.clear(); statementInspector.clear();
scope.inTransaction( entityManager -> { scope.inTransaction( entityManager -> {

View File

@ -26,7 +26,7 @@ import static org.hibernate.orm.test.mapping.onetoone.ToOneSelfReferenceTest.Ent
* @author Andrea Boriero * @author Andrea Boriero
*/ */
@DomainModel( annotatedClasses = { EntityTest.class } ) @DomainModel( annotatedClasses = { EntityTest.class } )
@SessionFactory(statementInspectorClass = SQLStatementInspector.class) @SessionFactory(useCollectingStatementInspector = true)
public class ToOneSelfReferenceTest { public class ToOneSelfReferenceTest {
@BeforeEach @BeforeEach
@ -48,7 +48,7 @@ public class ToOneSelfReferenceTest {
@Test @Test
public void testGet(SessionFactoryScope scope) { public void testGet(SessionFactoryScope scope) {
SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); SQLStatementInspector statementInspector = scope.getCollectingStatementInspector();
statementInspector.clear(); statementInspector.clear();
scope.inTransaction( scope.inTransaction(
session -> { session -> {

View File

@ -20,14 +20,14 @@ import jakarta.persistence.ManyToOne;
annotatedClasses = { HqlExplicitLeftJoinTest.EntityA.class, HqlExplicitLeftJoinTest.EntityB.class } annotatedClasses = { HqlExplicitLeftJoinTest.EntityA.class, HqlExplicitLeftJoinTest.EntityB.class }
) )
@SessionFactory( @SessionFactory(
statementInspectorClass = SQLStatementInspector.class useCollectingStatementInspector = true
) )
@TestForIssue( jiraKey = "HHH-15342") @TestForIssue( jiraKey = "HHH-15342")
public class HqlExplicitLeftJoinTest { public class HqlExplicitLeftJoinTest {
@Test @Test
public void testExplicitLeftJoin(SessionFactoryScope scope) { public void testExplicitLeftJoin(SessionFactoryScope scope) {
final SQLStatementInspector sqlStatementInterceptor = (SQLStatementInspector) scope.getStatementInspector(); final SQLStatementInspector sqlStatementInterceptor = scope.getCollectingStatementInspector();
sqlStatementInterceptor.clear(); sqlStatementInterceptor.clear();
scope.inTransaction( scope.inTransaction(
session -> { session -> {
@ -46,7 +46,7 @@ public class HqlExplicitLeftJoinTest {
@Test @Test
public void testExplicitLeftJoin2(SessionFactoryScope scope) { public void testExplicitLeftJoin2(SessionFactoryScope scope) {
final SQLStatementInspector sqlStatementInterceptor = (SQLStatementInspector) scope.getStatementInspector(); final SQLStatementInspector sqlStatementInterceptor = scope.getCollectingStatementInspector();
sqlStatementInterceptor.clear(); sqlStatementInterceptor.clear();
scope.inTransaction( scope.inTransaction(
session -> { session -> {
@ -65,7 +65,7 @@ public class HqlExplicitLeftJoinTest {
@Test @Test
public void testImplicitJoin(SessionFactoryScope scope) { public void testImplicitJoin(SessionFactoryScope scope) {
final SQLStatementInspector sqlStatementInterceptor = (SQLStatementInspector) scope.getStatementInspector(); final SQLStatementInspector sqlStatementInterceptor = scope.getCollectingStatementInspector();
sqlStatementInterceptor.clear(); sqlStatementInterceptor.clear();
scope.inTransaction( scope.inTransaction(
session -> { session -> {
@ -85,7 +85,7 @@ public class HqlExplicitLeftJoinTest {
@Test @Test
public void testImplicitJoin2(SessionFactoryScope scope) { public void testImplicitJoin2(SessionFactoryScope scope) {
final SQLStatementInspector sqlStatementInterceptor = (SQLStatementInspector) scope.getStatementInspector(); final SQLStatementInspector sqlStatementInterceptor = scope.getCollectingStatementInspector();
sqlStatementInterceptor.clear(); sqlStatementInterceptor.clear();
scope.inTransaction( scope.inTransaction(
session -> { session -> {
@ -104,7 +104,7 @@ public class HqlExplicitLeftJoinTest {
@Test @Test
public void testImplicitJoinWithNoExplicitJoins(SessionFactoryScope scope) { public void testImplicitJoinWithNoExplicitJoins(SessionFactoryScope scope) {
final SQLStatementInspector sqlStatementInterceptor = (SQLStatementInspector) scope.getStatementInspector(); final SQLStatementInspector sqlStatementInterceptor = scope.getCollectingStatementInspector();
sqlStatementInterceptor.clear(); sqlStatementInterceptor.clear();
scope.inTransaction( scope.inTransaction(
session -> { session -> {

View File

@ -24,13 +24,13 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
@DomainModel( @DomainModel(
annotatedClasses = { CompareEntityValuedPathsTest.Person.class } annotatedClasses = { CompareEntityValuedPathsTest.Person.class }
) )
@SessionFactory(statementInspectorClass = SQLStatementInspector.class) @SessionFactory(useCollectingStatementInspector = true)
@TestForIssue(jiraKey = "HHH-15349") @TestForIssue(jiraKey = "HHH-15349")
public class CompareEntityValuedPathsTest { public class CompareEntityValuedPathsTest {
@Test @Test
public void testCompareOneToManyUK(SessionFactoryScope scope) { public void testCompareOneToManyUK(SessionFactoryScope scope) {
final SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); final SQLStatementInspector statementInspector = scope.getCollectingStatementInspector();
scope.inTransaction( scope.inTransaction(
session -> { session -> {
statementInspector.clear(); statementInspector.clear();
@ -54,7 +54,7 @@ public class CompareEntityValuedPathsTest {
@Test @Test
public void testCompareOneToManyPK(SessionFactoryScope scope) { public void testCompareOneToManyPK(SessionFactoryScope scope) {
final SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); final SQLStatementInspector statementInspector = scope.getCollectingStatementInspector();
scope.inTransaction( scope.inTransaction(
session -> { session -> {
statementInspector.clear(); statementInspector.clear();
@ -78,7 +78,7 @@ public class CompareEntityValuedPathsTest {
@Test @Test
public void testManyToOneIsNull(SessionFactoryScope scope) { public void testManyToOneIsNull(SessionFactoryScope scope) {
final SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); final SQLStatementInspector statementInspector = scope.getCollectingStatementInspector();
scope.inTransaction( scope.inTransaction(
session -> { session -> {
statementInspector.clear(); statementInspector.clear();
@ -98,7 +98,7 @@ public class CompareEntityValuedPathsTest {
@Test @Test
public void testComparePKWithOneToManyUK(SessionFactoryScope scope) { public void testComparePKWithOneToManyUK(SessionFactoryScope scope) {
final SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); final SQLStatementInspector statementInspector = scope.getCollectingStatementInspector();
scope.inTransaction( scope.inTransaction(
session -> { session -> {
statementInspector.clear(); statementInspector.clear();
@ -123,7 +123,7 @@ public class CompareEntityValuedPathsTest {
@Test @Test
public void testCompareUKWithOneToManyPK(SessionFactoryScope scope) { public void testCompareUKWithOneToManyPK(SessionFactoryScope scope) {
final SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); final SQLStatementInspector statementInspector = scope.getCollectingStatementInspector();
scope.inTransaction( scope.inTransaction(
session -> { session -> {
statementInspector.clear(); statementInspector.clear();
@ -148,7 +148,7 @@ public class CompareEntityValuedPathsTest {
@Test @Test
public void testComparePKWithMappedByOneToManyPK(SessionFactoryScope scope) { public void testComparePKWithMappedByOneToManyPK(SessionFactoryScope scope) {
final SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); final SQLStatementInspector statementInspector = scope.getCollectingStatementInspector();
scope.inTransaction( scope.inTransaction(
session -> { session -> {
statementInspector.clear(); statementInspector.clear();
@ -172,7 +172,7 @@ public class CompareEntityValuedPathsTest {
@Test @Test
public void testComparePKWithMappedByOneToManyUK(SessionFactoryScope scope) { public void testComparePKWithMappedByOneToManyUK(SessionFactoryScope scope) {
final SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); final SQLStatementInspector statementInspector = scope.getCollectingStatementInspector();
scope.inTransaction( scope.inTransaction(
session -> { session -> {
statementInspector.clear(); statementInspector.clear();
@ -196,7 +196,7 @@ public class CompareEntityValuedPathsTest {
@Test @Test
public void testOneToManyUKIsNotNull(SessionFactoryScope scope) { public void testOneToManyUKIsNotNull(SessionFactoryScope scope) {
final SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); final SQLStatementInspector statementInspector = scope.getCollectingStatementInspector();
scope.inTransaction( scope.inTransaction(
session -> { session -> {
statementInspector.clear(); statementInspector.clear();
@ -217,7 +217,7 @@ public class CompareEntityValuedPathsTest {
@Test @Test
public void testOneToManyPKIsNotNull(SessionFactoryScope scope) { public void testOneToManyPKIsNotNull(SessionFactoryScope scope) {
final SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); final SQLStatementInspector statementInspector = scope.getCollectingStatementInspector();
scope.inTransaction( scope.inTransaction(
session -> { session -> {
statementInspector.clear(); statementInspector.clear();
@ -238,7 +238,7 @@ public class CompareEntityValuedPathsTest {
@Test @Test
public void testCompareOneToManyUKWithOneToManyPK(SessionFactoryScope scope) { public void testCompareOneToManyUKWithOneToManyPK(SessionFactoryScope scope) {
final SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); final SQLStatementInspector statementInspector = scope.getCollectingStatementInspector();
scope.inTransaction( scope.inTransaction(
session -> { session -> {
statementInspector.clear(); statementInspector.clear();
@ -260,7 +260,7 @@ public class CompareEntityValuedPathsTest {
@Test @Test
public void testCompareOneToManyPKWithOneToManyUK(SessionFactoryScope scope) { public void testCompareOneToManyPKWithOneToManyUK(SessionFactoryScope scope) {
final SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); final SQLStatementInspector statementInspector = scope.getCollectingStatementInspector();
scope.inTransaction( scope.inTransaction(
session -> { session -> {
statementInspector.clear(); statementInspector.clear();
@ -282,7 +282,7 @@ public class CompareEntityValuedPathsTest {
@Test @Test
public void testCompareOneToManyUKWithSubqueryOneToManyPK(SessionFactoryScope scope) { public void testCompareOneToManyUKWithSubqueryOneToManyPK(SessionFactoryScope scope) {
final SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); final SQLStatementInspector statementInspector = scope.getCollectingStatementInspector();
scope.inTransaction( scope.inTransaction(
session -> { session -> {
statementInspector.clear(); statementInspector.clear();
@ -303,7 +303,7 @@ public class CompareEntityValuedPathsTest {
@Test @Test
public void testCompareOneToManyPKWithSubqueryOneToManyUK(SessionFactoryScope scope) { public void testCompareOneToManyPKWithSubqueryOneToManyUK(SessionFactoryScope scope) {
final SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); final SQLStatementInspector statementInspector = scope.getCollectingStatementInspector();
scope.inTransaction( scope.inTransaction(
session -> { session -> {
statementInspector.clear(); statementInspector.clear();
@ -324,7 +324,7 @@ public class CompareEntityValuedPathsTest {
@Test @Test
public void testCompareManyToOneUK(SessionFactoryScope scope) { public void testCompareManyToOneUK(SessionFactoryScope scope) {
final SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); final SQLStatementInspector statementInspector = scope.getCollectingStatementInspector();
scope.inTransaction( scope.inTransaction(
session -> { session -> {
statementInspector.clear(); statementInspector.clear();
@ -347,7 +347,7 @@ public class CompareEntityValuedPathsTest {
@Test @Test
public void testCompareManyToOnePK(SessionFactoryScope scope) { public void testCompareManyToOnePK(SessionFactoryScope scope) {
final SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); final SQLStatementInspector statementInspector = scope.getCollectingStatementInspector();
scope.inTransaction( scope.inTransaction(
session -> { session -> {
statementInspector.clear(); statementInspector.clear();

View File

@ -13,11 +13,9 @@ import org.hibernate.cfg.AvailableSettings;
import org.hibernate.testing.TestForIssue; import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.jdbc.SQLStatementInspector; 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.EntityManagerFactoryScope;
import org.hibernate.testing.orm.junit.Jpa; import org.hibernate.testing.orm.junit.Jpa;
import org.hibernate.testing.orm.junit.Setting; 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.BeforeAll;
import org.junit.jupiter.api.Test; 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.USE_SQL_COMMENTS, value = "true"),
@Setting(name = AvailableSettings.IN_CLAUSE_PARAMETER_PADDING, value = "true"), @Setting(name = AvailableSettings.IN_CLAUSE_PARAMETER_PADDING, value = "true"),
}, },
settingProviders = { useCollectingStatementInspector = true
@SettingProvider(
settingName = AvailableSettings.STATEMENT_INSPECTOR,
provider = DefaultSQLStatementInspectorSettingProvider.class
)
}
) )
public class InClauseParameterPaddingCriteriaTest { public class InClauseParameterPaddingCriteriaTest {
@ -62,7 +55,7 @@ public class InClauseParameterPaddingCriteriaTest {
@Test @Test
public void testInClauseParameterPadding(EntityManagerFactoryScope scope) { public void testInClauseParameterPadding(EntityManagerFactoryScope scope) {
final SQLStatementInspector statementInspector = scope.getStatementInspector( SQLStatementInspector.class ); final SQLStatementInspector statementInspector = scope.getCollectingStatementInspector();
statementInspector.clear(); statementInspector.clear();
scope.inTransaction( entityManager -> { scope.inTransaction( entityManager -> {
@ -86,7 +79,7 @@ public class InClauseParameterPaddingCriteriaTest {
@Test @Test
public void testInClauseParameterPaddingForExpressions(EntityManagerFactoryScope scope) { public void testInClauseParameterPaddingForExpressions(EntityManagerFactoryScope scope) {
final SQLStatementInspector statementInspector = scope.getStatementInspector( SQLStatementInspector.class ); final SQLStatementInspector statementInspector = scope.getCollectingStatementInspector();
statementInspector.clear(); statementInspector.clear();
scope.inTransaction( entityManager -> { scope.inTransaction( entityManager -> {

View File

@ -12,11 +12,9 @@ import org.hibernate.cfg.AvailableSettings;
import org.hibernate.testing.TestForIssue; import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.jdbc.SQLStatementInspector; 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.EntityManagerFactoryScope;
import org.hibernate.testing.orm.junit.Jpa; import org.hibernate.testing.orm.junit.Jpa;
import org.hibernate.testing.orm.junit.Setting; 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.BeforeEach;
import org.junit.jupiter.api.Test; 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.USE_SQL_COMMENTS, value = "true"),
@Setting(name = AvailableSettings.IN_CLAUSE_PARAMETER_PADDING, value = "true") @Setting(name = AvailableSettings.IN_CLAUSE_PARAMETER_PADDING, value = "true")
}, },
settingProviders = { useCollectingStatementInspector = true
@SettingProvider(
settingName = AvailableSettings.STATEMENT_INSPECTOR,
provider = DefaultSQLStatementInspectorSettingProvider.class
)
}
) )
public class InClauseParameterPaddingTest { public class InClauseParameterPaddingTest {
@ -76,7 +69,7 @@ public class InClauseParameterPaddingTest {
EntityManagerFactoryScope scope, EntityManagerFactoryScope scope,
String expectedInClause, String expectedInClause,
Integer... ids) { Integer... ids) {
final SQLStatementInspector sqlStatementInterceptor = scope.getStatementInspector( SQLStatementInspector.class ); final SQLStatementInspector sqlStatementInterceptor = scope.getCollectingStatementInspector();
sqlStatementInterceptor.clear(); sqlStatementInterceptor.clear();
scope.inTransaction( entityManager -> { scope.inTransaction( entityManager -> {

View File

@ -14,7 +14,6 @@ import org.hibernate.dialect.H2Dialect;
import org.hibernate.testing.TestForIssue; import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.jdbc.SQLStatementInspector; 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.EntityManagerFactoryScope;
import org.hibernate.testing.orm.junit.Jpa; import org.hibernate.testing.orm.junit.Jpa;
import org.hibernate.testing.orm.junit.RequiresDialect; import org.hibernate.testing.orm.junit.RequiresDialect;
@ -43,12 +42,9 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
@SettingProvider( @SettingProvider(
settingName = AvailableSettings.DIALECT, settingName = AvailableSettings.DIALECT,
provider = MaxInExpressionParameterPaddingTest.DialectProvider.class provider = MaxInExpressionParameterPaddingTest.DialectProvider.class
),
@SettingProvider(
settingName = AvailableSettings.STATEMENT_INSPECTOR,
provider = DefaultSQLStatementInspectorSettingProvider.class
) )
} },
useCollectingStatementInspector = true
) )
public class MaxInExpressionParameterPaddingTest { public class MaxInExpressionParameterPaddingTest {
@ -76,7 +72,7 @@ public class MaxInExpressionParameterPaddingTest {
@Test @Test
public void testInClauseParameterPadding(EntityManagerFactoryScope scope) { public void testInClauseParameterPadding(EntityManagerFactoryScope scope) {
final SQLStatementInspector statementInspector = scope.getStatementInspector( SQLStatementInspector.class ); final SQLStatementInspector statementInspector = scope.getCollectingStatementInspector();
statementInspector.clear(); statementInspector.clear();
scope.inTransaction( entityManager -> scope.inTransaction( entityManager ->
@ -98,7 +94,7 @@ public class MaxInExpressionParameterPaddingTest {
@TestForIssue(jiraKey = "HHH-14109") @TestForIssue(jiraKey = "HHH-14109")
@Test @Test
public void testInClauseParameterPaddingToLimit(EntityManagerFactoryScope scope) { public void testInClauseParameterPaddingToLimit(EntityManagerFactoryScope scope) {
final SQLStatementInspector statementInspector = scope.getStatementInspector( SQLStatementInspector.class ); final SQLStatementInspector statementInspector = scope.getCollectingStatementInspector();
statementInspector.clear(); statementInspector.clear();
scope.inTransaction( scope.inTransaction(
@ -123,7 +119,7 @@ public class MaxInExpressionParameterPaddingTest {
@Test @Test
public void testInClauseParameterSplittingAfterLimit(EntityManagerFactoryScope scope) { public void testInClauseParameterSplittingAfterLimit(EntityManagerFactoryScope scope) {
final SQLStatementInspector statementInspector = scope.getStatementInspector( SQLStatementInspector.class ); final SQLStatementInspector statementInspector = scope.getCollectingStatementInspector();
statementInspector.clear(); statementInspector.clear();
scope.inTransaction( scope.inTransaction(
@ -149,7 +145,7 @@ public class MaxInExpressionParameterPaddingTest {
@Test @Test
public void testInClauseParameterSplittingAfterLimit2(EntityManagerFactoryScope scope) { public void testInClauseParameterSplittingAfterLimit2(EntityManagerFactoryScope scope) {
final SQLStatementInspector statementInspector = scope.getStatementInspector( SQLStatementInspector.class ); final SQLStatementInspector statementInspector = scope.getCollectingStatementInspector();
statementInspector.clear(); statementInspector.clear();
scope.inTransaction( scope.inTransaction(
@ -175,7 +171,7 @@ public class MaxInExpressionParameterPaddingTest {
@Test @Test
public void testInClauseParameterSplittingAfterLimit3(EntityManagerFactoryScope scope) { public void testInClauseParameterSplittingAfterLimit3(EntityManagerFactoryScope scope) {
final SQLStatementInspector statementInspector = scope.getStatementInspector( SQLStatementInspector.class ); final SQLStatementInspector statementInspector = scope.getCollectingStatementInspector();
statementInspector.clear(); statementInspector.clear();
scope.inTransaction( scope.inTransaction(

View File

@ -30,7 +30,7 @@ import static org.assertj.core.api.Assertions.assertThat;
*/ */
@ServiceRegistry @ServiceRegistry
@DomainModel(standardModels = StandardDomainModel.CONTACTS) @DomainModel(standardModels = StandardDomainModel.CONTACTS)
@SessionFactory( statementInspectorClass = SQLStatementInspector.class ) @SessionFactory( useCollectingStatementInspector = true )
public class GroupByTest { public class GroupByTest {
@Test @Test
@ -46,7 +46,7 @@ public class GroupByTest {
@Test @Test
@TestForIssue( jiraKey = "HHH-9301" ) @TestForIssue( jiraKey = "HHH-9301" )
public void testGroupByAliasedBasicPart(SessionFactoryScope scope) { public void testGroupByAliasedBasicPart(SessionFactoryScope scope) {
final SQLStatementInspector sqlStatementInspector = (SQLStatementInspector) scope.getStatementInspector(); final SQLStatementInspector sqlStatementInspector = scope.getCollectingStatementInspector();
sqlStatementInspector.clear(); sqlStatementInspector.clear();
scope.inSession( (session) -> { scope.inSession( (session) -> {
@ -67,7 +67,7 @@ public class GroupByTest {
@Test @Test
@TestForIssue( jiraKey = "HHH-9301" ) @TestForIssue( jiraKey = "HHH-9301" )
public void testGroupByAliasedCompositePart(SessionFactoryScope scope) { public void testGroupByAliasedCompositePart(SessionFactoryScope scope) {
final SQLStatementInspector sqlStatementInspector = (SQLStatementInspector) scope.getStatementInspector(); final SQLStatementInspector sqlStatementInspector = scope.getCollectingStatementInspector();
sqlStatementInspector.clear(); sqlStatementInspector.clear();
scope.inTransaction( (session) -> { scope.inTransaction( (session) -> {
@ -92,7 +92,7 @@ public class GroupByTest {
@Test @Test
@TestForIssue( jiraKey = "HHH-9301" ) @TestForIssue( jiraKey = "HHH-9301" )
public void testGroupByMultipleAliases(SessionFactoryScope scope) { public void testGroupByMultipleAliases(SessionFactoryScope scope) {
final SQLStatementInspector sqlStatementInspector = (SQLStatementInspector) scope.getStatementInspector(); final SQLStatementInspector sqlStatementInspector = scope.getCollectingStatementInspector();
sqlStatementInspector.clear(); sqlStatementInspector.clear();
scope.inTransaction( (session) -> { scope.inTransaction( (session) -> {

View File

@ -30,7 +30,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
InsertSelectTests.EntityEntry.class, InsertSelectTests.EntityEntry.class,
InsertSelectTests.EntitySource.class InsertSelectTests.EntitySource.class
}) })
@SessionFactory(statementInspectorClass = SQLStatementInspector.class) @SessionFactory(useCollectingStatementInspector = true)
public class InsertSelectTests { public class InsertSelectTests {
@BeforeEach @BeforeEach
@ -55,7 +55,7 @@ public class InsertSelectTests {
@Test @Test
@TestForIssue( jiraKey = "HHH-15527") @TestForIssue( jiraKey = "HHH-15527")
public void testInsertSelectGeneratedAssigned(SessionFactoryScope scope) { public void testInsertSelectGeneratedAssigned(SessionFactoryScope scope) {
final SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); final SQLStatementInspector statementInspector = scope.getCollectingStatementInspector();
scope.inTransaction( scope.inTransaction(
session -> { session -> {
statementInspector.clear(); statementInspector.clear();

View File

@ -25,13 +25,13 @@ import static org.assertj.core.api.Assertions.assertThat;
*/ */
@TestForIssue( jiraKey = "HHH-14201" ) @TestForIssue( jiraKey = "HHH-14201" )
@DomainModel( annotatedClasses = { JoinOrderTest.EntityA.class, JoinOrderTest.EntityB.class, JoinOrderTest.EntityC.class } ) @DomainModel( annotatedClasses = { JoinOrderTest.EntityA.class, JoinOrderTest.EntityB.class, JoinOrderTest.EntityC.class } )
@SessionFactory( statementInspectorClass = SQLStatementInspector.class ) @SessionFactory( useCollectingStatementInspector = true )
public class JoinOrderTest { public class JoinOrderTest {
@Test @Test
public void testJoinOrder(SessionFactoryScope scope) { public void testJoinOrder(SessionFactoryScope scope) {
scope.inTransaction( (session) -> { scope.inTransaction( (session) -> {
final SQLStatementInspector sqlStatementInspector = (SQLStatementInspector) scope.getStatementInspector(); final SQLStatementInspector sqlStatementInspector = scope.getCollectingStatementInspector();
sqlStatementInspector.clear(); sqlStatementInspector.clear();
final String hql = "select 1" final String hql = "select 1"

View File

@ -10,15 +10,12 @@ import java.util.List;
import java.util.Locale; import java.util.Locale;
import org.hibernate.Hibernate; import org.hibernate.Hibernate;
import org.hibernate.cfg.AvailableSettings;
import org.hibernate.testing.TestForIssue; import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.jdbc.SQLStatementInspector; import org.hibernate.testing.jdbc.SQLStatementInspector;
import org.hibernate.testing.orm.junit.DomainModel; 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.SessionFactory;
import org.hibernate.testing.orm.junit.SessionFactoryScope; 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.AfterEach;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
@ -30,13 +27,10 @@ import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
@TestForIssue(jiraKey = "HHH-13944") @TestForIssue(jiraKey = "HHH-13944")
@ServiceRegistry(
settings = @Setting( name = AvailableSettings.STATEMENT_INSPECTOR, value = "org.hibernate.testing.jdbc.SQLStatementInspector" )
)
@DomainModel( @DomainModel(
annotatedClasses = { Skill.class, Teacher.class, Student.class } annotatedClasses = { Skill.class, Teacher.class, Student.class }
) )
@SessionFactory @SessionFactory( useCollectingStatementInspector = true )
public class OneToManySizeTest2 { public class OneToManySizeTest2 {
@Test @Test
public void testSize(SessionFactoryScope scope) { public void testSize(SessionFactoryScope scope) {

View File

@ -43,7 +43,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
@DomainModel( @DomainModel(
annotatedClasses = { OracleQueryHintTest.Employee.class, OracleQueryHintTest.Department.class } annotatedClasses = { OracleQueryHintTest.Employee.class, OracleQueryHintTest.Department.class }
) )
@SessionFactory(statementInspectorClass = SQLStatementInspector.class) @SessionFactory(useCollectingStatementInspector = true)
@ServiceRegistry( @ServiceRegistry(
settings = @Setting(name = AvailableSettings.USE_SQL_COMMENTS, value = "true") settings = @Setting(name = AvailableSettings.USE_SQL_COMMENTS, value = "true")
) )
@ -67,7 +67,7 @@ public class OracleQueryHintTest {
@Test @Test
public void testQueryHint(SessionFactoryScope scope) { public void testQueryHint(SessionFactoryScope scope) {
final SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); final SQLStatementInspector statementInspector = scope.getCollectingStatementInspector();
statementInspector.clear(); statementInspector.clear();
// test Query w/ a simple Oracle optimizer hint // test Query w/ a simple Oracle optimizer hint
@ -141,7 +141,7 @@ public class OracleQueryHintTest {
@Test @Test
@TestForIssue(jiraKey = "HHH-12362") @TestForIssue(jiraKey = "HHH-12362")
public void testQueryHintAndComment(SessionFactoryScope scope) { public void testQueryHintAndComment(SessionFactoryScope scope) {
final SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); final SQLStatementInspector statementInspector = scope.getCollectingStatementInspector();
statementInspector.clear(); statementInspector.clear();
scope.inTransaction( s -> { scope.inTransaction( s -> {
@ -165,7 +165,7 @@ public class OracleQueryHintTest {
@Test @Test
@TestForIssue(jiraKey = "HHH-13608") @TestForIssue(jiraKey = "HHH-13608")
public void testQueryHintCaseInsensitive(SessionFactoryScope scope) { public void testQueryHintCaseInsensitive(SessionFactoryScope scope) {
final SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); final SQLStatementInspector statementInspector = scope.getCollectingStatementInspector();
statementInspector.clear(); statementInspector.clear();
scope.inTransaction( s -> { scope.inTransaction( s -> {

View File

@ -30,7 +30,7 @@ import static org.junit.Assert.assertThat;
* @author Nathan Xu * @author Nathan Xu
*/ */
@DomainModel( annotatedClasses = RowIdTest.Product.class ) @DomainModel( annotatedClasses = RowIdTest.Product.class )
@SessionFactory(statementInspectorClass = SQLStatementInspector.class) @SessionFactory(useCollectingStatementInspector = true)
public class RowIdTest { public class RowIdTest {
@BeforeEach @BeforeEach
@ -50,7 +50,7 @@ public class RowIdTest {
scope.inTransaction( session -> { scope.inTransaction( session -> {
String rowId = scope.getSessionFactory().getJdbcServices().getDialect().rowId(""); String rowId = scope.getSessionFactory().getJdbcServices().getDialect().rowId("");
SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); SQLStatementInspector statementInspector = scope.getCollectingStatementInspector();
statementInspector.clear(); statementInspector.clear();
Product product = session.find( Product.class, "1L" ); Product product = session.find( Product.class, "1L" );

View File

@ -44,7 +44,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
) )
@SessionFactory( @SessionFactory(
generateStatistics = true, generateStatistics = true,
statementInspectorClass = SQLStatementInspector.class) useCollectingStatementInspector = true)
public class EmbeddedWithManyToOneTest { public class EmbeddedWithManyToOneTest {
@BeforeEach @BeforeEach
@ -73,7 +73,7 @@ public class EmbeddedWithManyToOneTest {
@Test @Test
public void testGet(SessionFactoryScope scope) { public void testGet(SessionFactoryScope scope) {
SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); SQLStatementInspector statementInspector = scope.getCollectingStatementInspector();
statementInspector.clear(); statementInspector.clear();
scope.inTransaction( scope.inTransaction(
session -> { session -> {
@ -87,7 +87,7 @@ public class EmbeddedWithManyToOneTest {
@Test @Test
public void testHqlSelect(SessionFactoryScope scope) { public void testHqlSelect(SessionFactoryScope scope) {
SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); SQLStatementInspector statementInspector = scope.getCollectingStatementInspector();
statementInspector.clear(); statementInspector.clear();
scope.inTransaction( scope.inTransaction(
session -> { session -> {

View File

@ -37,7 +37,7 @@ import static org.junit.Assert.assertTrue;
} }
) )
@ServiceRegistry @ServiceRegistry
@SessionFactory(generateStatistics = true, statementInspectorClass = SQLStatementInspector.class) @SessionFactory(generateStatistics = true, useCollectingStatementInspector = true)
public class EntityWithManyToOneSelfReferenceTest { public class EntityWithManyToOneSelfReferenceTest {
@BeforeEach @BeforeEach
@ -96,7 +96,7 @@ public class EntityWithManyToOneSelfReferenceTest {
@Test @Test
public void testGetEntity(SessionFactoryScope scope) { public void testGetEntity(SessionFactoryScope scope) {
SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); SQLStatementInspector statementInspector = scope.getCollectingStatementInspector();
statementInspector.clear(); statementInspector.clear();
scope.inTransaction( scope.inTransaction(
session -> { session -> {

View File

@ -45,7 +45,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
} }
) )
@ServiceRegistry @ServiceRegistry
@SessionFactory(statementInspectorClass = SQLStatementInspector.class) @SessionFactory(useCollectingStatementInspector = true)
public class EntityWithBidirectionalAssociationsOneOfWhichIsAJoinTableTest { public class EntityWithBidirectionalAssociationsOneOfWhichIsAJoinTableTest {
@BeforeEach @BeforeEach
@ -78,7 +78,7 @@ public class EntityWithBidirectionalAssociationsOneOfWhichIsAJoinTableTest {
@Test @Test
public void testGetParent(SessionFactoryScope scope) { public void testGetParent(SessionFactoryScope scope) {
SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); SQLStatementInspector statementInspector = scope.getCollectingStatementInspector();
statementInspector.clear(); statementInspector.clear();
scope.inTransaction( scope.inTransaction(
session -> { session -> {
@ -108,7 +108,7 @@ public class EntityWithBidirectionalAssociationsOneOfWhichIsAJoinTableTest {
@Test @Test
public void testGetChild(SessionFactoryScope scope) { public void testGetChild(SessionFactoryScope scope) {
SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); SQLStatementInspector statementInspector = scope.getCollectingStatementInspector();
statementInspector.clear(); statementInspector.clear();
scope.inTransaction( session -> { scope.inTransaction( session -> {
final Male son = session.get( Male.class, 2 ); final Male son = session.get( Male.class, 2 );
@ -142,7 +142,7 @@ public class EntityWithBidirectionalAssociationsOneOfWhichIsAJoinTableTest {
@Test @Test
public void testHqlSelectSon(SessionFactoryScope scope) { public void testHqlSelectSon(SessionFactoryScope scope) {
SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); SQLStatementInspector statementInspector = scope.getCollectingStatementInspector();
statementInspector.clear(); statementInspector.clear();
scope.inTransaction( scope.inTransaction(
session -> { session -> {
@ -168,7 +168,7 @@ public class EntityWithBidirectionalAssociationsOneOfWhichIsAJoinTableTest {
public void testHqlSelectParent(SessionFactoryScope scope) { public void testHqlSelectParent(SessionFactoryScope scope) {
scope.inTransaction( scope.inTransaction(
session -> { session -> {
SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); SQLStatementInspector statementInspector = scope.getCollectingStatementInspector();
statementInspector.clear(); statementInspector.clear();
final Parent parent = session.createQuery( final Parent parent = session.createQuery(
"SELECT p FROM Parent p JOIN p.son WHERE p.id = :id", "SELECT p FROM Parent p JOIN p.son WHERE p.id = :id",

View File

@ -16,7 +16,6 @@ import org.hibernate.validator.internal.util.Contracts;
import org.hibernate.testing.jdbc.SQLStatementInspector; import org.hibernate.testing.jdbc.SQLStatementInspector;
import org.hibernate.testing.orm.junit.DomainModel; 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.ServiceRegistry;
import org.hibernate.testing.orm.junit.SessionFactory; import org.hibernate.testing.orm.junit.SessionFactory;
import org.hibernate.testing.orm.junit.SessionFactoryScope; import org.hibernate.testing.orm.junit.SessionFactoryScope;
@ -48,7 +47,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
} }
) )
@ServiceRegistry @ServiceRegistry
@SessionFactory(statementInspectorClass = SQLStatementInspector.class) @SessionFactory(useCollectingStatementInspector = true)
public class EntityWithBidirectionalOneToOneTest { public class EntityWithBidirectionalOneToOneTest {
@BeforeEach @BeforeEach
@ -77,7 +76,7 @@ public class EntityWithBidirectionalOneToOneTest {
@Test @Test
public void testGetMother(SessionFactoryScope scope) { public void testGetMother(SessionFactoryScope scope) {
SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); SQLStatementInspector statementInspector = scope.getCollectingStatementInspector();
statementInspector.clear(); statementInspector.clear();
scope.inTransaction( session -> { scope.inTransaction( session -> {
final Mother mother = session.get( Mother.class, 1 ); final Mother mother = session.get( Mother.class, 1 );
@ -141,7 +140,7 @@ public class EntityWithBidirectionalOneToOneTest {
session.save( adoptedChild ); session.save( adoptedChild );
} ); } );
SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); SQLStatementInspector statementInspector = scope.getCollectingStatementInspector();
statementInspector.clear(); statementInspector.clear();
scope.inTransaction( session -> { scope.inTransaction( session -> {
final Mother mother = session.get( Mother.class, 4 ); final Mother mother = session.get( Mother.class, 4 );
@ -194,7 +193,7 @@ public class EntityWithBidirectionalOneToOneTest {
session.save( anotherChild ); session.save( anotherChild );
} ); } );
SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); SQLStatementInspector statementInspector = scope.getCollectingStatementInspector();
statementInspector.clear(); statementInspector.clear();
scope.inTransaction( session -> { scope.inTransaction( session -> {
final Mother mother = session.get( Mother.class, 4 ); final Mother mother = session.get( Mother.class, 4 );
@ -236,7 +235,7 @@ public class EntityWithBidirectionalOneToOneTest {
@Test @Test
public void testGetChild(SessionFactoryScope scope) { public void testGetChild(SessionFactoryScope scope) {
SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); SQLStatementInspector statementInspector = scope.getCollectingStatementInspector();
statementInspector.clear(); statementInspector.clear();
scope.inTransaction( session -> { scope.inTransaction( session -> {
final Child child = session.get( Child.class, 2 ); final Child child = session.get( Child.class, 2 );
@ -293,7 +292,7 @@ public class EntityWithBidirectionalOneToOneTest {
session.get( AdoptedChild.class, 3 ).setBiologicalMother( mother ); session.get( AdoptedChild.class, 3 ).setBiologicalMother( mother );
} }
); );
SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); SQLStatementInspector statementInspector = scope.getCollectingStatementInspector();
statementInspector.clear(); statementInspector.clear();
scope.inTransaction( session -> { scope.inTransaction( session -> {
final Child child = session.get( Child.class, 2 ); final Child child = session.get( Child.class, 2 );
@ -335,7 +334,7 @@ public class EntityWithBidirectionalOneToOneTest {
@Test @Test
public void testGetAdoptedChild(SessionFactoryScope scope) { public void testGetAdoptedChild(SessionFactoryScope scope) {
SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); SQLStatementInspector statementInspector = scope.getCollectingStatementInspector();
statementInspector.clear(); statementInspector.clear();
scope.inTransaction( session -> { scope.inTransaction( session -> {
final AdoptedChild adoptedChild = session.get( AdoptedChild.class, 3 ); final AdoptedChild adoptedChild = session.get( AdoptedChild.class, 3 );
@ -407,7 +406,7 @@ public class EntityWithBidirectionalOneToOneTest {
session.save( child3 ); session.save( child3 );
} ); } );
SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); SQLStatementInspector statementInspector = scope.getCollectingStatementInspector();
statementInspector.clear(); statementInspector.clear();
scope.inTransaction( session -> { scope.inTransaction( session -> {
final Child child = session.get( Child.class, 5 ); final Child child = session.get( Child.class, 5 );
@ -457,7 +456,7 @@ public class EntityWithBidirectionalOneToOneTest {
@Test @Test
public void testHqlSelectMother(SessionFactoryScope scope) { public void testHqlSelectMother(SessionFactoryScope scope) {
SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); SQLStatementInspector statementInspector = scope.getCollectingStatementInspector();
statementInspector.clear(); statementInspector.clear();
scope.inTransaction( scope.inTransaction(
session -> { session -> {
@ -481,7 +480,7 @@ public class EntityWithBidirectionalOneToOneTest {
@Test @Test
public void testHqlSelectChild(SessionFactoryScope scope) { public void testHqlSelectChild(SessionFactoryScope scope) {
SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector(); SQLStatementInspector statementInspector = scope.getCollectingStatementInspector();
statementInspector.clear(); statementInspector.clear();
scope.inTransaction( scope.inTransaction(
session -> { session -> {

View File

@ -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<SQLStatementInspector> {
@Override
public SQLStatementInspector getSetting() {
return new SQLStatementInspector();
}
}

View File

@ -15,6 +15,7 @@ import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.engine.spi.SessionImplementor; import org.hibernate.engine.spi.SessionImplementor;
import org.hibernate.resource.jdbc.spi.StatementInspector; import org.hibernate.resource.jdbc.spi.StatementInspector;
import org.hibernate.testing.jdbc.SQLStatementInspector;
import org.hibernate.testing.orm.transaction.TransactionUtil; import org.hibernate.testing.orm.transaction.TransactionUtil;
import org.junit.jupiter.api.extension.ExtensionContext; import org.junit.jupiter.api.extension.ExtensionContext;
@ -55,6 +56,11 @@ abstract class AbstractEntityManagerFactoryScope implements EntityManagerFactory
return (T) getStatementInspector(); return (T) getStatementInspector();
} }
@Override
public SQLStatementInspector getCollectingStatementInspector() {
return getStatementInspector( SQLStatementInspector.class );
}
@Override @Override
public void close() { public void close() {
if ( !active ) { if ( !active ) {

View File

@ -31,6 +31,7 @@ import org.hibernate.tool.schema.Action;
import org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator; import org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator;
import org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.ActionGrouping; import org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.ActionGrouping;
import org.hibernate.testing.jdbc.SQLStatementInspector;
import org.hibernate.testing.jdbc.SharedDriverManagerConnectionProviderImpl; import org.hibernate.testing.jdbc.SharedDriverManagerConnectionProviderImpl;
import org.hibernate.testing.orm.domain.DomainModelDescriptor; import org.hibernate.testing.orm.domain.DomainModelDescriptor;
import org.hibernate.testing.orm.domain.StandardDomainModel; import org.hibernate.testing.orm.domain.StandardDomainModel;
@ -164,7 +165,6 @@ public class EntityManagerFactoryExtension
final Map<String, Object> integrationSettings = new HashMap<>(); final Map<String, Object> integrationSettings = new HashMap<>();
integrationSettings.put( PersistentTableStrategy.DROP_ID_TABLES, "true" ); integrationSettings.put( PersistentTableStrategy.DROP_ID_TABLES, "true" );
integrationSettings.put( GlobalTemporaryTableMutationStrategy.DROP_ID_TABLES, "true" ); integrationSettings.put( GlobalTemporaryTableMutationStrategy.DROP_ID_TABLES, "true" );
integrationSettings.put( LocalTemporaryTableMutationStrategy.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 ); final EntityManagerFactoryScopeImpl scope = new EntityManagerFactoryScopeImpl( pui, integrationSettings );
locateExtensionStore( testInstance, context ).put( EMF_KEY, scope ); locateExtensionStore( testInstance, context ).put( EMF_KEY, scope );

View File

@ -13,6 +13,8 @@ import jakarta.persistence.EntityManagerFactory;
import org.hibernate.resource.jdbc.spi.StatementInspector; import org.hibernate.resource.jdbc.spi.StatementInspector;
import org.hibernate.testing.jdbc.SQLStatementInspector;
/** /**
* @author Steve Ebersole * @author Steve Ebersole
*/ */
@ -22,6 +24,7 @@ public interface EntityManagerFactoryScope {
StatementInspector getStatementInspector(); StatementInspector getStatementInspector();
<T extends StatementInspector> T getStatementInspector(Class<T> type); <T extends StatementInspector> T getStatementInspector(Class<T> type);
SQLStatementInspector getCollectingStatementInspector();
void inEntityManager(Consumer<EntityManager> action); void inEntityManager(Consumer<EntityManager> action);
void inTransaction(Consumer<EntityManager> action); void inTransaction(Consumer<EntityManager> action);

View File

@ -17,8 +17,8 @@ import jakarta.persistence.ValidationMode;
import jakarta.persistence.spi.PersistenceUnitTransactionType; import jakarta.persistence.spi.PersistenceUnitTransactionType;
import org.hibernate.jpa.spi.JpaCompliance; 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.DomainModelDescriptor;
import org.hibernate.testing.orm.domain.StandardDomainModel; import org.hibernate.testing.orm.domain.StandardDomainModel;
import org.junit.jupiter.api.TestInstance; import org.junit.jupiter.api.TestInstance;
@ -122,4 +122,12 @@ public @interface Jpa {
String[] annotatedClassNames() default {}; String[] annotatedClassNames() default {};
String[] annotatedPackageNames() default {}; String[] annotatedPackageNames() default {};
String[] xmlMappings() 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;
} }