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 = {
Card.class, CardField.class, Key.class
})
@SessionFactory(statementInspectorClass = SQLStatementInspector.class)
@SessionFactory(useCollectingStatementInspector = true)
public class EagerKeyManyToOneTest {
public static final String CARD_ID = "cardId";
public static final String CARD_MODEL = "Gran Torino";
@ -65,7 +65,7 @@ public class EagerKeyManyToOneTest {
// meant to test against regression relating to http://opensource.atlassian.com/projects/hibernate/browse/HHH-2277
// and http://opensource.atlassian.com/projects/hibernate/browse/HHH-4147
SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector();
SQLStatementInspector statementInspector = scope.getCollectingStatementInspector();
statementInspector.clear();
scope.inTransaction(
session -> {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -29,7 +29,7 @@ import jakarta.persistence.ManyToOne;
HHH15065Test.Person.class,
}
)
@SessionFactory
@SessionFactory(useCollectingStatementInspector = true)
class HHH15065Test {
@Test
@ -43,7 +43,7 @@ class HHH15065Test {
.getResultList();
} );
SQLStatementInspector statementInspector = (SQLStatementInspector) scope.getStatementInspector();
SQLStatementInspector statementInspector = scope.getCollectingStatementInspector();
List<String> sqlQueries = statementInspector.getSqlQueries();
assertEquals( 1, sqlQueries.size() );
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;
import java.util.Set;
import org.hibernate.query.criteria.HibernateCriteriaBuilder;
import org.hibernate.query.criteria.JpaCriteriaQuery;
import org.hibernate.query.criteria.JpaRoot;
@ -36,13 +34,13 @@ import jakarta.persistence.criteria.JoinType;
ManyToOneJoinReuseTest.BookList.class
}
)
@SessionFactory(statementInspectorClass = SQLStatementInspector.class)
@SessionFactory(useCollectingStatementInspector = true)
public class ManyToOneJoinReuseTest {
@Test
@TestForIssue(jiraKey = "HHH-15648")
public void fetchAndImplicitPath(SessionFactoryScope scope) {
SQLStatementInspector sqlStatementInterceptor = (SQLStatementInspector) scope.getStatementInspector();
SQLStatementInspector sqlStatementInterceptor = scope.getCollectingStatementInspector();
sqlStatementInterceptor.clear();
scope.inTransaction(
session -> {
@ -62,7 +60,7 @@ public class ManyToOneJoinReuseTest {
@Test
@TestForIssue(jiraKey = "HHH-15645")
public void joinAndImplicitPath(SessionFactoryScope scope) {
SQLStatementInspector sqlStatementInterceptor = (SQLStatementInspector) scope.getStatementInspector();
SQLStatementInspector sqlStatementInterceptor = scope.getCollectingStatementInspector();
sqlStatementInterceptor.clear();
scope.inTransaction(
session -> {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

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

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.ActionGrouping;
import org.hibernate.testing.jdbc.SQLStatementInspector;
import org.hibernate.testing.jdbc.SharedDriverManagerConnectionProviderImpl;
import org.hibernate.testing.orm.domain.DomainModelDescriptor;
import org.hibernate.testing.orm.domain.StandardDomainModel;
@ -164,7 +165,6 @@ public class EntityManagerFactoryExtension
final Map<String, Object> integrationSettings = new HashMap<>();
integrationSettings.put( PersistentTableStrategy.DROP_ID_TABLES, "true" );
integrationSettings.put( GlobalTemporaryTableMutationStrategy.DROP_ID_TABLES, "true" );
integrationSettings.put( LocalTemporaryTableMutationStrategy.DROP_ID_TABLES, "true" );
@ -190,6 +190,15 @@ public class EntityManagerFactoryExtension
}
}
// statement inspector
if ( emfAnn.useCollectingStatementInspector() ) {
String inspectorSetting = (String) integrationSettings.get( AvailableSettings.STATEMENT_INSPECTOR );
if ( !(inspectorSetting == null || inspectorSetting.isBlank()) ) {
log.warn( String.format( "Overriding the explicit \"%1s\" statement inspector setting", inspectorSetting ) );
}
integrationSettings.put( AvailableSettings.STATEMENT_INSPECTOR, new SQLStatementInspector() );
}
final EntityManagerFactoryScopeImpl scope = new EntityManagerFactoryScopeImpl( pui, integrationSettings );
locateExtensionStore( testInstance, context ).put( EMF_KEY, scope );

View File

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

View File

@ -17,8 +17,8 @@ import jakarta.persistence.ValidationMode;
import jakarta.persistence.spi.PersistenceUnitTransactionType;
import org.hibernate.jpa.spi.JpaCompliance;
import org.hibernate.resource.jdbc.spi.StatementInspector;
import org.hibernate.testing.jdbc.SQLStatementInspector;
import org.hibernate.testing.orm.domain.DomainModelDescriptor;
import org.hibernate.testing.orm.domain.StandardDomainModel;
import org.junit.jupiter.api.TestInstance;
@ -122,4 +122,12 @@ public @interface Jpa {
String[] annotatedClassNames() default {};
String[] annotatedPackageNames() default {};
String[] xmlMappings() default {};
/**
* Shorthand for adding {@code @Setting( name = AvailableSettings.STATEMENT_INSPECTOR, value = "org.hibernate.testing.jdbc.SQLStatementInspector"}
* to the integration settings.
* Note: if the statement inspector is also explicitly specified as a setting, it will be overridden by the shortcut
* @see SQLStatementInspector
*/
boolean useCollectingStatementInspector() default false;
}