From c4401452dd61b532a03a2c54eba5ef14ab9e32fa Mon Sep 17 00:00:00 2001 From: Jan Schatteman Date: Thu, 21 Oct 2021 22:38:57 +0200 Subject: [PATCH] Enable a SettingProvider[] in @Jpa and refactor away the NonStringValueSettingProvider class Signed-off-by: Jan Schatteman --- ...eDiscardPersistenceContextOnCloseTest.java | 8 ++++- ...eDiscardPersistenceContextOnCloseTest.java | 8 ++++- .../EntityManagerSerializationTest.java | 11 +++++-- .../NotSerializableClassSettingProvider.java | 22 ++++++++++++++ ...SerializableClassSettingValueProvider.java | 30 ------------------- ...onnectionProviderSettingValueProvider.java | 25 ---------------- ...ratorProviderClassNameSettingProvider.java | 13 ++------ ...gratorProviderInstanceSettingProvider.java | 13 ++------ ...ntegrationProviderSettingByObjectTest.java | 9 +++++- ...ntegrationProviderSettingByStringTest.java | 9 +++++- .../test/jpa/mapping/DefaultCascadeTest.java | 19 ++++++------ ...ntityManagerWithActiveTransactionTest.java | 8 ++++- .../JtaGetTransactionThrowsExceptionTest.java | 8 ++++- ...r.java => JtaPlatformSettingProvider.java} | 13 ++------ .../JtaReusingEntityTransactionTest.java | 11 ++++++- .../transaction/SynchronizationTypeTest.java | 8 ++++- .../transaction/TransactionJoiningTest.java | 9 +++++- ...actionRolledBackInDifferentThreadTest.java | 9 +++++- .../batch/AbstractJtaBatchTest.java | 12 ++------ .../batch/JtaWithFailingBatchTest.java | 30 +++++++++++-------- .../batch/JtaWithStatementsBatchTest.java | 30 +++++++++++-------- .../hibernate/orm/test/jpa/xml/XmlTest.java | 18 +++++------ .../OneToOneMapsIdJoinColumnTest.java | 18 +++++------ ...tSpyConnectionProviderSettingProvider.java | 2 +- .../jpa/NonStringValueSettingProvider.java | 15 ---------- .../junit/EntityManagerFactoryExtension.java | 19 +++++------- .../org/hibernate/testing/orm/junit/Jpa.java | 5 ++-- 27 files changed, 192 insertions(+), 190 deletions(-) create mode 100644 hibernate-core/src/test/java/org/hibernate/orm/test/jpa/ejb3configuration/NotSerializableClassSettingProvider.java delete mode 100644 hibernate-core/src/test/java/org/hibernate/orm/test/jpa/ejb3configuration/NotSerializableClassSettingValueProvider.java delete mode 100644 hibernate-core/src/test/java/org/hibernate/orm/test/jpa/ejb3configuration/PreparedStatementSpyConnectionProviderSettingValueProvider.java rename hibernate-core/src/test/java/org/hibernate/orm/test/jpa/transaction/{JtaPlatformNonStringValueSettingProvider.java => JtaPlatformSettingProvider.java} (57%) delete mode 100644 hibernate-testing/src/main/java/org/hibernate/testing/orm/jpa/NonStringValueSettingProvider.java diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/ejb3configuration/DisableDiscardPersistenceContextOnCloseTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/ejb3configuration/DisableDiscardPersistenceContextOnCloseTest.java index 9f220843a3..521ea77e2b 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/ejb3configuration/DisableDiscardPersistenceContextOnCloseTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/ejb3configuration/DisableDiscardPersistenceContextOnCloseTest.java @@ -12,12 +12,14 @@ import java.util.Map; import org.hibernate.cfg.AvailableSettings; import org.hibernate.orm.test.jpa.Wallet; +import org.hibernate.testing.orm.jdbc.PreparedStatementSpyConnectionProviderSettingProvider; import org.hibernate.testing.orm.junit.DialectFeatureChecks; import org.hibernate.testing.orm.junit.EntityManagerFactoryScope; import org.hibernate.testing.orm.junit.Jpa; import org.hibernate.testing.orm.junit.RequiresDialectFeature; import org.hibernate.testing.orm.junit.Setting; import org.hibernate.testing.orm.jdbc.PreparedStatementSpyConnectionProvider; +import org.hibernate.testing.orm.junit.SettingProvider; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; @@ -33,7 +35,11 @@ import static org.junit.jupiter.api.Assertions.assertTrue; @Jpa( annotatedClasses = { Wallet.class }, integrationSettings = { @Setting( name = AvailableSettings.DISCARD_PC_ON_CLOSE, value = "false") }, - nonStringValueSettingProviders = { PreparedStatementSpyConnectionProviderSettingValueProvider.class } + settingProviders = { + @SettingProvider( + settingName = AvailableSettings.CONNECTION_PROVIDER, + provider = PreparedStatementSpyConnectionProviderSettingProvider.class) + } ) public class DisableDiscardPersistenceContextOnCloseTest { diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/ejb3configuration/EnableDiscardPersistenceContextOnCloseTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/ejb3configuration/EnableDiscardPersistenceContextOnCloseTest.java index 90a77c8c69..5c8480e9fc 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/ejb3configuration/EnableDiscardPersistenceContextOnCloseTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/ejb3configuration/EnableDiscardPersistenceContextOnCloseTest.java @@ -11,12 +11,14 @@ import java.util.Map; import org.hibernate.cfg.AvailableSettings; import org.hibernate.orm.test.jpa.Wallet; +import org.hibernate.testing.orm.jdbc.PreparedStatementSpyConnectionProviderSettingProvider; import org.hibernate.testing.orm.junit.DialectFeatureChecks; import org.hibernate.testing.orm.junit.RequiresDialectFeature; 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.jdbc.PreparedStatementSpyConnectionProvider; +import org.hibernate.testing.orm.junit.SettingProvider; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; @@ -31,7 +33,11 @@ import static org.junit.jupiter.api.Assertions.fail; @Jpa( annotatedClasses = { Wallet.class }, integrationSettings = { @Setting(name = AvailableSettings.DISCARD_PC_ON_CLOSE, value = "true") }, - nonStringValueSettingProviders = { PreparedStatementSpyConnectionProviderSettingValueProvider.class } + settingProviders = { + @SettingProvider( + settingName = AvailableSettings.CONNECTION_PROVIDER, + provider = PreparedStatementSpyConnectionProviderSettingProvider.class) + } ) public class EnableDiscardPersistenceContextOnCloseTest { diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/ejb3configuration/EntityManagerSerializationTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/ejb3configuration/EntityManagerSerializationTest.java index 5c3e403eca..28b6a5f053 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/ejb3configuration/EntityManagerSerializationTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/ejb3configuration/EntityManagerSerializationTest.java @@ -12,7 +12,6 @@ import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import java.util.Date; -import jakarta.persistence.EntityManager; import org.hibernate.Session; import org.hibernate.orm.test.jpa.Cat; @@ -23,9 +22,11 @@ import org.hibernate.orm.test.jpa.Wallet; 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.Test; +import jakarta.persistence.EntityManager; + /** * @author Emmanuel Bernard * @author Scott Marlow @@ -38,7 +39,11 @@ import org.junit.jupiter.api.Test; Cat.class, Kitten.class }, - nonStringValueSettingProviders = { NotSerializableClassSettingValueProvider.class } + settingProviders = { + @SettingProvider( + settingName = "BaseEntityManagerFunctionalTestCase.getConfig_addedNotSerializableObject", + provider = NotSerializableClassSettingProvider.class) + } ) public class EntityManagerSerializationTest { @Test diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/ejb3configuration/NotSerializableClassSettingProvider.java b/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/ejb3configuration/NotSerializableClassSettingProvider.java new file mode 100644 index 0000000000..3377bbacbb --- /dev/null +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/ejb3configuration/NotSerializableClassSettingProvider.java @@ -0,0 +1,22 @@ +/* + * 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 . + */ +package org.hibernate.orm.test.jpa.ejb3configuration; + +import org.hibernate.orm.test.jpa.NotSerializableClass; + +import org.hibernate.testing.orm.junit.SettingProvider; + +/** + * Add a non-serializable object to the EMF to ensure that the EM can be serialized even if its EMF is not serializable. + * This will ensure that the fix for HHH-6897 doesn't regress + */ +public class NotSerializableClassSettingProvider implements SettingProvider.Provider { + @Override + public NotSerializableClass getSetting() { + return new NotSerializableClass(); + } +} diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/ejb3configuration/NotSerializableClassSettingValueProvider.java b/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/ejb3configuration/NotSerializableClassSettingValueProvider.java deleted file mode 100644 index 7edb9035df..0000000000 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/ejb3configuration/NotSerializableClassSettingValueProvider.java +++ /dev/null @@ -1,30 +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 . - */ -package org.hibernate.orm.test.jpa.ejb3configuration; - -import org.hibernate.orm.test.jpa.NotSerializableClass; - -import org.hibernate.testing.orm.jpa.NonStringValueSettingProvider; - -/** - * @author Jan Schatteman - * - * Used by EntityManagerSerializationTest - * Add a non-serializable object to the EMF to ensure that the EM can be serialized even if its EMF is not serializable. - * This will ensure that the fix for HHH-6897 doesn't regress, - */ -public class NotSerializableClassSettingValueProvider extends NonStringValueSettingProvider { - @Override - public String getKey() { - return "BaseEntityManagerFunctionalTestCase.getConfig_addedNotSerializableObject"; - } - - @Override - public Object getValue() { - return new NotSerializableClass(); - } -} \ No newline at end of file diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/ejb3configuration/PreparedStatementSpyConnectionProviderSettingValueProvider.java b/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/ejb3configuration/PreparedStatementSpyConnectionProviderSettingValueProvider.java deleted file mode 100644 index 994445ed43..0000000000 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/ejb3configuration/PreparedStatementSpyConnectionProviderSettingValueProvider.java +++ /dev/null @@ -1,25 +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 . - */ -package org.hibernate.orm.test.jpa.ejb3configuration; - -import org.hibernate.testing.orm.jpa.NonStringValueSettingProvider; -import org.hibernate.testing.orm.jdbc.PreparedStatementSpyConnectionProvider; - -/** - * @author Jan Schatteman - */ -public class PreparedStatementSpyConnectionProviderSettingValueProvider extends NonStringValueSettingProvider { - @Override - public String getKey() { - return org.hibernate.cfg.AvailableSettings.CONNECTION_PROVIDER; - } - - @Override - public Object getValue() { - return new PreparedStatementSpyConnectionProvider( false, false ); - } -} \ No newline at end of file diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/integrationprovider/DtoIntegratorProviderClassNameSettingProvider.java b/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/integrationprovider/DtoIntegratorProviderClassNameSettingProvider.java index 20a545d998..c0807ebc76 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/integrationprovider/DtoIntegratorProviderClassNameSettingProvider.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/integrationprovider/DtoIntegratorProviderClassNameSettingProvider.java @@ -6,21 +6,14 @@ */ package org.hibernate.orm.test.jpa.integrationprovider; -import org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl; - -import org.hibernate.testing.orm.jpa.NonStringValueSettingProvider; +import org.hibernate.testing.orm.junit.SettingProvider; /** * @author Jan Schatteman */ -public class DtoIntegratorProviderClassNameSettingProvider extends NonStringValueSettingProvider { +public class DtoIntegratorProviderClassNameSettingProvider implements SettingProvider.Provider { @Override - public String getKey() { - return EntityManagerFactoryBuilderImpl.INTEGRATOR_PROVIDER; - } - - @Override - public Object getValue() { + public String getSetting() { return DtoIntegratorProvider.class.getName(); } } diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/integrationprovider/DtoIntegratorProviderInstanceSettingProvider.java b/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/integrationprovider/DtoIntegratorProviderInstanceSettingProvider.java index 7e84df7139..2cc5bae18f 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/integrationprovider/DtoIntegratorProviderInstanceSettingProvider.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/integrationprovider/DtoIntegratorProviderInstanceSettingProvider.java @@ -6,21 +6,14 @@ */ package org.hibernate.orm.test.jpa.integrationprovider; -import org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl; - -import org.hibernate.testing.orm.jpa.NonStringValueSettingProvider; +import org.hibernate.testing.orm.junit.SettingProvider; /** * @author Jan Schatteman */ -public class DtoIntegratorProviderInstanceSettingProvider extends NonStringValueSettingProvider { +public class DtoIntegratorProviderInstanceSettingProvider implements SettingProvider.Provider { @Override - public String getKey() { - return EntityManagerFactoryBuilderImpl.INTEGRATOR_PROVIDER; - } - - @Override - public Object getValue() { + public DtoIntegratorProvider getSetting() { return new DtoIntegratorProvider(); } } diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/integrationprovider/IntegrationProviderSettingByObjectTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/integrationprovider/IntegrationProviderSettingByObjectTest.java index b7a7cf52b1..833e05e3a1 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/integrationprovider/IntegrationProviderSettingByObjectTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/integrationprovider/IntegrationProviderSettingByObjectTest.java @@ -8,9 +8,12 @@ package org.hibernate.orm.test.jpa.integrationprovider; import java.util.List; +import org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl; + import org.hibernate.testing.TestForIssue; 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.Test; @@ -23,7 +26,11 @@ import org.junit.jupiter.api.Test; annotatedClasses = { Person.class }, - nonStringValueSettingProviders = { DtoIntegratorProviderInstanceSettingProvider.class } + settingProviders = { + @SettingProvider( + settingName = EntityManagerFactoryBuilderImpl.INTEGRATOR_PROVIDER, + provider = DtoIntegratorProviderInstanceSettingProvider.class ) + } ) public class IntegrationProviderSettingByObjectTest { diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/integrationprovider/IntegrationProviderSettingByStringTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/integrationprovider/IntegrationProviderSettingByStringTest.java index ebe25221d3..ade6eb883c 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/integrationprovider/IntegrationProviderSettingByStringTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/integrationprovider/IntegrationProviderSettingByStringTest.java @@ -8,9 +8,12 @@ package org.hibernate.orm.test.jpa.integrationprovider; import java.util.List; +import org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl; + import org.hibernate.testing.TestForIssue; 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.Test; @@ -22,7 +25,11 @@ import org.junit.jupiter.api.Test; annotatedClasses = { Person.class }, - nonStringValueSettingProviders = { DtoIntegratorProviderClassNameSettingProvider.class } + settingProviders = { + @SettingProvider( + settingName = EntityManagerFactoryBuilderImpl.INTEGRATOR_PROVIDER, + provider = DtoIntegratorProviderClassNameSettingProvider.class ) + } ) public class IntegrationProviderSettingByStringTest { diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/mapping/DefaultCascadeTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/mapping/DefaultCascadeTest.java index 3a4ec35efa..d638ccc2fc 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/mapping/DefaultCascadeTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/mapping/DefaultCascadeTest.java @@ -7,6 +7,8 @@ package org.hibernate.orm.test.jpa.mapping; import java.util.Arrays; +import java.util.List; + import jakarta.persistence.Entity; import jakarta.persistence.GeneratedValue; import jakarta.persistence.Id; @@ -15,9 +17,9 @@ import jakarta.persistence.Table; import org.hibernate.cfg.AvailableSettings; -import org.hibernate.testing.orm.jpa.NonStringValueSettingProvider; 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.Test; @@ -31,7 +33,11 @@ import org.junit.jupiter.api.Test; DefaultCascadeTest.Child.class }, // using 'xmlMappings = { "org/hibernate/orm/test/jpa/mapping/orm.xml" }' also works - nonStringValueSettingProviders = { DefaultCascadeTest.EJB3DDMappingProvider.class } + settingProviders = { + @SettingProvider( + settingName = AvailableSettings.ORM_XML_FILES, + provider = DefaultCascadeTest.EJB3DDMappingProvider.class ) + } ) public class DefaultCascadeTest { @@ -79,14 +85,9 @@ public class DefaultCascadeTest { private Parent parent; } - public static class EJB3DDMappingProvider extends NonStringValueSettingProvider { + public static class EJB3DDMappingProvider implements SettingProvider.Provider> { @Override - public String getKey() { - return AvailableSettings.ORM_XML_FILES; - } - - @Override - public Object getValue() { + public List getSetting() { return Arrays.asList( "org/hibernate/orm/test/jpa/mapping/orm.xml" ); } } diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/transaction/CloseEntityManagerWithActiveTransactionTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/transaction/CloseEntityManagerWithActiveTransactionTest.java index dac69d8793..21bee415e7 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/transaction/CloseEntityManagerWithActiveTransactionTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/transaction/CloseEntityManagerWithActiveTransactionTest.java @@ -33,6 +33,7 @@ import org.hibernate.testing.jta.TestingJtaPlatformImpl; 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.AfterEach; import org.junit.jupiter.api.Test; @@ -56,7 +57,12 @@ import static org.junit.jupiter.api.Assertions.assertTrue; @Setting(name = AvailableSettings.JPA_TRANSACTION_TYPE, value = "JTA"), @Setting(name = AvailableSettings.JPA_TRANSACTION_COMPLIANCE, value = "true") }, - nonStringValueSettingProviders = { JtaPlatformNonStringValueSettingProvider.class } + settingProviders = { + @SettingProvider( + settingName = AvailableSettings.JTA_PLATFORM, + provider = JtaPlatformSettingProvider.class + ) + } ) public class CloseEntityManagerWithActiveTransactionTest { diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/transaction/JtaGetTransactionThrowsExceptionTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/transaction/JtaGetTransactionThrowsExceptionTest.java index f35e5ef25c..4dce1245ca 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/transaction/JtaGetTransactionThrowsExceptionTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/transaction/JtaGetTransactionThrowsExceptionTest.java @@ -14,6 +14,7 @@ import org.hibernate.testing.TestForIssue; 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.Test; import static org.junit.jupiter.api.Assertions.assertThrows; @@ -27,7 +28,12 @@ import static org.junit.jupiter.api.Assertions.assertThrows; @Setting(name = AvailableSettings.CONNECTION_PROVIDER, value = "org.hibernate.testing.jta.JtaAwareConnectionProviderImpl"), @Setting( name = AvailableSettings.JPA_TRANSACTION_COMPLIANCE, value = "true") }, - nonStringValueSettingProviders = { JtaPlatformNonStringValueSettingProvider.class } + settingProviders = { + @SettingProvider( + settingName = AvailableSettings.JTA_PLATFORM, + provider = JtaPlatformSettingProvider.class + ) + } ) public class JtaGetTransactionThrowsExceptionTest { diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/transaction/JtaPlatformNonStringValueSettingProvider.java b/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/transaction/JtaPlatformSettingProvider.java similarity index 57% rename from hibernate-core/src/test/java/org/hibernate/orm/test/jpa/transaction/JtaPlatformNonStringValueSettingProvider.java rename to hibernate-core/src/test/java/org/hibernate/orm/test/jpa/transaction/JtaPlatformSettingProvider.java index 2b638ef899..2bee543368 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/transaction/JtaPlatformNonStringValueSettingProvider.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/transaction/JtaPlatformSettingProvider.java @@ -6,22 +6,15 @@ */ package org.hibernate.orm.test.jpa.transaction; -import org.hibernate.cfg.AvailableSettings; - import org.hibernate.testing.jta.TestingJtaPlatformImpl; -import org.hibernate.testing.orm.jpa.NonStringValueSettingProvider; +import org.hibernate.testing.orm.junit.SettingProvider; /** * @author Jan Schatteman */ -public class JtaPlatformNonStringValueSettingProvider extends NonStringValueSettingProvider { +public class JtaPlatformSettingProvider implements SettingProvider.Provider { @Override - public String getKey() { - return AvailableSettings.JTA_PLATFORM; - } - - @Override - public Object getValue() { + public TestingJtaPlatformImpl getSetting() { return TestingJtaPlatformImpl.INSTANCE; } } diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/transaction/JtaReusingEntityTransactionTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/transaction/JtaReusingEntityTransactionTest.java index 0fd5399faa..ee7238a03b 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/transaction/JtaReusingEntityTransactionTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/transaction/JtaReusingEntityTransactionTest.java @@ -7,6 +7,9 @@ package org.hibernate.orm.test.jpa.transaction; import java.util.List; + +import org.hibernate.cfg.AvailableSettings; + import jakarta.persistence.Entity; import jakarta.persistence.EntityTransaction; import jakarta.persistence.GeneratedValue; @@ -15,6 +18,7 @@ import jakarta.persistence.Id; 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.Test; @@ -30,7 +34,12 @@ import static org.hamcrest.MatcherAssert.assertThat; @Setting(name = org.hibernate.cfg.AvailableSettings.CONNECTION_PROVIDER, value = "org.hibernate.testing.jta.JtaAwareConnectionProviderImpl"), @Setting(name = org.hibernate.cfg.AvailableSettings.JPA_TRANSACTION_TYPE, value = "JTA") }, - nonStringValueSettingProviders = { JtaPlatformNonStringValueSettingProvider.class } + settingProviders = { + @SettingProvider( + settingName = AvailableSettings.JTA_PLATFORM, + provider = JtaPlatformSettingProvider.class + ) + } ) public class JtaReusingEntityTransactionTest { diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/transaction/SynchronizationTypeTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/transaction/SynchronizationTypeTest.java index 8c7d8a4b94..4a596df8e6 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/transaction/SynchronizationTypeTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/transaction/SynchronizationTypeTest.java @@ -26,6 +26,7 @@ import org.hibernate.testing.orm.junit.EntityManagerFactoryScope; import org.hibernate.testing.orm.junit.ExtraAssertions; 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.Test; import static org.junit.jupiter.api.Assertions.assertFalse; @@ -48,7 +49,12 @@ import static org.junit.jupiter.api.Assertions.fail; }, - nonStringValueSettingProviders = { JtaPlatformNonStringValueSettingProvider.class } + settingProviders = { + @SettingProvider( + settingName = AvailableSettings.JTA_PLATFORM, + provider = JtaPlatformSettingProvider.class + ) + } ) public class SynchronizationTypeTest { diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/transaction/TransactionJoiningTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/transaction/TransactionJoiningTest.java index 4a8452f43b..5f6ae32ce2 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/transaction/TransactionJoiningTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/transaction/TransactionJoiningTest.java @@ -15,6 +15,7 @@ import jakarta.transaction.Status; import jakarta.transaction.TransactionManager; import org.hibernate.HibernateException; +import org.hibernate.cfg.AvailableSettings; import org.hibernate.engine.spi.SharedSessionContractImplementor; import org.hibernate.engine.transaction.internal.jta.JtaStatusHelper; import org.hibernate.internal.SessionImpl; @@ -27,6 +28,7 @@ import org.hibernate.testing.orm.junit.EntityManagerFactoryScope; import org.hibernate.testing.orm.junit.ExtraAssertions; 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.Assertions; import org.junit.jupiter.api.Test; @@ -46,7 +48,12 @@ import static org.junit.jupiter.api.Assertions.assertTrue; @Setting(name = org.hibernate.cfg.AvailableSettings.CONNECTION_PROVIDER, value = "org.hibernate.testing.jta.JtaAwareConnectionProviderImpl"), @Setting(name = org.hibernate.cfg.AvailableSettings.JPA_TRANSACTION_TYPE, value = "JTA") }, - nonStringValueSettingProviders = { JtaPlatformNonStringValueSettingProvider.class } + settingProviders = { + @SettingProvider( + settingName = AvailableSettings.JTA_PLATFORM, + provider = JtaPlatformSettingProvider.class + ) + } ) public class TransactionJoiningTest { diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/transaction/TransactionRolledBackInDifferentThreadTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/transaction/TransactionRolledBackInDifferentThreadTest.java index 45798d5cc3..82de8562e3 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/transaction/TransactionRolledBackInDifferentThreadTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/transaction/TransactionRolledBackInDifferentThreadTest.java @@ -13,11 +13,13 @@ import jakarta.transaction.SystemException; import jakarta.transaction.TransactionManager; import org.hibernate.HibernateException; +import org.hibernate.cfg.AvailableSettings; import org.hibernate.testing.jta.TestingJtaPlatformImpl; 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.Test; import static org.junit.jupiter.api.Assertions.fail; @@ -33,7 +35,12 @@ import static org.junit.jupiter.api.Assertions.fail; @Setting(name = org.hibernate.cfg.AvailableSettings.CONNECTION_PROVIDER, value = "org.hibernate.testing.jta.JtaAwareConnectionProviderImpl"), @Setting(name = org.hibernate.cfg.AvailableSettings.JPA_TRANSACTION_TYPE, value = "JTA") }, - nonStringValueSettingProviders = { JtaPlatformNonStringValueSettingProvider.class } + settingProviders = { + @SettingProvider( + settingName = AvailableSettings.JTA_PLATFORM, + provider = JtaPlatformSettingProvider.class + ) + } ) public class TransactionRolledBackInDifferentThreadTest { diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/transaction/batch/AbstractJtaBatchTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/transaction/batch/AbstractJtaBatchTest.java index d7821d6e63..03e2c5d82f 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/transaction/batch/AbstractJtaBatchTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/transaction/batch/AbstractJtaBatchTest.java @@ -17,13 +17,12 @@ import jakarta.persistence.Table; import org.hibernate.annotations.GenericGenerator; import org.hibernate.annotations.Parameter; -import org.hibernate.cfg.AvailableSettings; import org.hibernate.internal.HEMLogging; import org.hibernate.jpa.boot.spi.ProviderChecker; import org.hibernate.testing.jta.JtaAwareConnectionProviderImpl; import org.hibernate.testing.logger.Triggerable; -import org.hibernate.testing.orm.jpa.NonStringValueSettingProvider; +import org.hibernate.testing.orm.junit.SettingProvider; import org.hibernate.testing.orm.logger.LoggerInspectionExtension; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.extension.RegisterExtension; @@ -63,14 +62,9 @@ public abstract class AbstractJtaBatchTest { } ); } - public static class ConnectionNonStringValueSettingProvider extends NonStringValueSettingProvider { + public static class ConnectionSettingProvider implements SettingProvider.Provider { @Override - public String getKey() { - return AvailableSettings.CONNECTION_PROVIDER; - } - - @Override - public Object getValue() { + public String getSetting() { return JtaAwareConnectionProviderImpl.class.getName(); } } diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/transaction/batch/JtaWithFailingBatchTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/transaction/batch/JtaWithFailingBatchTest.java index 24f045404a..b863cb5991 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/transaction/batch/JtaWithFailingBatchTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/transaction/batch/JtaWithFailingBatchTest.java @@ -21,16 +21,16 @@ import org.hibernate.engine.jdbc.batch.internal.BatchingBatch; import org.hibernate.engine.jdbc.batch.spi.Batch; import org.hibernate.engine.jdbc.batch.spi.BatchKey; import org.hibernate.engine.jdbc.spi.JdbcCoordinator; -import org.hibernate.orm.test.jpa.transaction.JtaPlatformNonStringValueSettingProvider; +import org.hibernate.orm.test.jpa.transaction.JtaPlatformSettingProvider; import org.hibernate.testing.TestForIssue; import org.hibernate.testing.jta.TestingJtaPlatformImpl; -import org.hibernate.testing.orm.jpa.NonStringValueSettingProvider; import org.hibernate.testing.orm.junit.DialectFeatureChecks; import org.hibernate.testing.orm.junit.EntityManagerFactoryScope; import org.hibernate.testing.orm.junit.Jpa; import org.hibernate.testing.orm.junit.RequiresDialectFeature; import org.hibernate.testing.orm.junit.Setting; +import org.hibernate.testing.orm.junit.SettingProvider; import org.junit.jupiter.api.Test; @@ -56,10 +56,19 @@ import static org.junit.jupiter.api.Assertions.fail; @Setting(name = AvailableSettings.JPA_TRANSACTION_COMPLIANCE, value = "true"), @Setting(name = AvailableSettings.STATEMENT_BATCH_SIZE, value = "50") }, - nonStringValueSettingProviders = { - JtaPlatformNonStringValueSettingProvider.class, - AbstractJtaBatchTest.ConnectionNonStringValueSettingProvider.class, - JtaWithFailingBatchTest.BatchBuilderNonStringValueSettingProvider.class + settingProviders = { + @SettingProvider( + settingName = AvailableSettings.CONNECTION_PROVIDER, + provider = AbstractJtaBatchTest.ConnectionSettingProvider.class + ), + @SettingProvider( + settingName = AvailableSettings.JTA_PLATFORM, + provider = JtaPlatformSettingProvider.class + ), + @SettingProvider( + settingName = BatchBuilderInitiator.BUILDER, + provider = JtaWithFailingBatchTest.BatchBuilderSettingProvider.class + ) } ) public class JtaWithFailingBatchTest extends AbstractJtaBatchTest { @@ -133,14 +142,9 @@ public class JtaWithFailingBatchTest extends AbstractJtaBatchTest { ); } - public static class BatchBuilderNonStringValueSettingProvider extends NonStringValueSettingProvider { + public static class BatchBuilderSettingProvider implements SettingProvider.Provider { @Override - public String getKey() { - return BatchBuilderInitiator.BUILDER; - } - - @Override - public Object getValue() { + public String getSetting() { return TestBatchBuilder.class.getName(); } } diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/transaction/batch/JtaWithStatementsBatchTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/transaction/batch/JtaWithStatementsBatchTest.java index c4bc58f403..4b7347cf39 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/transaction/batch/JtaWithStatementsBatchTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/transaction/batch/JtaWithStatementsBatchTest.java @@ -20,16 +20,16 @@ import org.hibernate.engine.jdbc.batch.internal.BatchingBatch; import org.hibernate.engine.jdbc.batch.spi.Batch; import org.hibernate.engine.jdbc.batch.spi.BatchKey; import org.hibernate.engine.jdbc.spi.JdbcCoordinator; -import org.hibernate.orm.test.jpa.transaction.JtaPlatformNonStringValueSettingProvider; +import org.hibernate.orm.test.jpa.transaction.JtaPlatformSettingProvider; import org.hibernate.testing.TestForIssue; import org.hibernate.testing.jta.TestingJtaPlatformImpl; -import org.hibernate.testing.orm.jpa.NonStringValueSettingProvider; import org.hibernate.testing.orm.junit.DialectFeatureChecks; import org.hibernate.testing.orm.junit.EntityManagerFactoryScope; import org.hibernate.testing.orm.junit.Jpa; import org.hibernate.testing.orm.junit.RequiresDialectFeature; import org.hibernate.testing.orm.junit.Setting; +import org.hibernate.testing.orm.junit.SettingProvider; import org.junit.jupiter.api.Test; import static org.hamcrest.MatcherAssert.assertThat; @@ -52,10 +52,19 @@ import static org.junit.jupiter.api.Assertions.assertFalse; @Setting(name = AvailableSettings.JPA_TRANSACTION_COMPLIANCE, value = "true"), @Setting(name = AvailableSettings.STATEMENT_BATCH_SIZE, value = "50") }, - nonStringValueSettingProviders = { - JtaPlatformNonStringValueSettingProvider.class, - AbstractJtaBatchTest.ConnectionNonStringValueSettingProvider.class, - JtaWithStatementsBatchTest.BatchBuilderNonStringValueSettingProvider.class + settingProviders = { + @SettingProvider( + settingName = AvailableSettings.CONNECTION_PROVIDER, + provider = AbstractJtaBatchTest.ConnectionSettingProvider.class + ), + @SettingProvider( + settingName = AvailableSettings.JTA_PLATFORM, + provider = JtaPlatformSettingProvider.class + ), + @SettingProvider( + settingName = BatchBuilderInitiator.BUILDER, + provider = JtaWithStatementsBatchTest.BatchBuilderSettingProvider.class + ) } ) public class JtaWithStatementsBatchTest extends AbstractJtaBatchTest { @@ -161,14 +170,9 @@ public class JtaWithStatementsBatchTest extends AbstractJtaBatchTest { ); } - public static class BatchBuilderNonStringValueSettingProvider extends NonStringValueSettingProvider { + public static class BatchBuilderSettingProvider implements SettingProvider.Provider { @Override - public String getKey() { - return BatchBuilderInitiator.BUILDER; - } - - @Override - public Object getValue() { + public String getSetting() { return TestBatchBuilder.class.getName(); } } diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/xml/XmlTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/xml/XmlTest.java index 17b79d62e8..ade0e9156d 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/xml/XmlTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/xml/XmlTest.java @@ -13,9 +13,9 @@ import org.hibernate.cfg.AvailableSettings; import org.hibernate.engine.spi.SharedSessionContractImplementor; import org.hibernate.persister.entity.EntityPersister; -import org.hibernate.testing.orm.jpa.NonStringValueSettingProvider; 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.Test; import org.junit.jupiter.api.Assertions; @@ -25,7 +25,12 @@ import org.junit.jupiter.api.Assertions; */ @Jpa( xmlMappings = {"org/hibernate/orm/test/jpa/xml/orm.xml", "org/hibernate/orm/test/jpa/xml/orm2.xml"}, - nonStringValueSettingProviders = { XmlTest.SharedCacheModeProvider.class } + settingProviders = { + @SettingProvider( + settingName = AvailableSettings.JAKARTA_SHARED_CACHE_MODE, + provider = XmlTest.SharedCacheModeProvider.class + ) + } ) public class XmlTest { @Test @@ -43,14 +48,9 @@ public class XmlTest { Assertions.assertTrue(entityPersister.canWriteToCache()); } - public static class SharedCacheModeProvider extends NonStringValueSettingProvider { + public static class SharedCacheModeProvider implements SettingProvider.Provider { @Override - public String getKey() { - return AvailableSettings.JPA_SHARED_CACHE_MODE; - } - - @Override - public Object getValue() { + public SharedCacheMode getSetting() { return SharedCacheMode.ENABLE_SELECTIVE; } } diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/onetoone/OneToOneMapsIdJoinColumnTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/onetoone/OneToOneMapsIdJoinColumnTest.java index 348c874714..8f3bb143d2 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/onetoone/OneToOneMapsIdJoinColumnTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/onetoone/OneToOneMapsIdJoinColumnTest.java @@ -18,9 +18,9 @@ import org.hibernate.SessionFactory; import org.hibernate.cfg.AvailableSettings; import org.hibernate.testing.jdbc.SQLStatementInspector; -import org.hibernate.testing.orm.jpa.NonStringValueSettingProvider; 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; @@ -34,18 +34,18 @@ import static org.junit.jupiter.api.Assertions.assertSame; OneToOneMapsIdJoinColumnTest.Person.class, OneToOneMapsIdJoinColumnTest.PersonDetails.class }, - nonStringValueSettingProviders = { OneToOneMapsIdJoinColumnTest.SQLStatementInspectorProvider.class } + settingProviders = { + @SettingProvider( + settingName = AvailableSettings.STATEMENT_INSPECTOR, + provider = OneToOneMapsIdJoinColumnTest.SQLStatementInspectorProvider.class + ) + } ) public class OneToOneMapsIdJoinColumnTest { - public static class SQLStatementInspectorProvider extends NonStringValueSettingProvider { + public static class SQLStatementInspectorProvider implements SettingProvider.Provider { @Override - public String getKey() { - return AvailableSettings.STATEMENT_INSPECTOR; - } - - @Override - public Object getValue() { + public Class getSetting() { return SQLStatementInspector.class; } } diff --git a/hibernate-testing/src/main/java/org/hibernate/testing/orm/jdbc/PreparedStatementSpyConnectionProviderSettingProvider.java b/hibernate-testing/src/main/java/org/hibernate/testing/orm/jdbc/PreparedStatementSpyConnectionProviderSettingProvider.java index 565f2f6534..a4722cc93a 100644 --- a/hibernate-testing/src/main/java/org/hibernate/testing/orm/jdbc/PreparedStatementSpyConnectionProviderSettingProvider.java +++ b/hibernate-testing/src/main/java/org/hibernate/testing/orm/jdbc/PreparedStatementSpyConnectionProviderSettingProvider.java @@ -14,6 +14,6 @@ import org.hibernate.testing.orm.junit.SettingProvider; public class PreparedStatementSpyConnectionProviderSettingProvider implements SettingProvider.Provider { @Override public PreparedStatementSpyConnectionProvider getSetting() { - return new PreparedStatementSpyConnectionProvider( true, false ); + return new PreparedStatementSpyConnectionProvider( false, false ); } } diff --git a/hibernate-testing/src/main/java/org/hibernate/testing/orm/jpa/NonStringValueSettingProvider.java b/hibernate-testing/src/main/java/org/hibernate/testing/orm/jpa/NonStringValueSettingProvider.java deleted file mode 100644 index 127f097ea3..0000000000 --- a/hibernate-testing/src/main/java/org/hibernate/testing/orm/jpa/NonStringValueSettingProvider.java +++ /dev/null @@ -1,15 +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 . - */ -package org.hibernate.testing.orm.jpa; - -/** - * @author Jan Schatteman - */ -public abstract class NonStringValueSettingProvider { - public abstract String getKey(); - public abstract Object getValue(); -} diff --git a/hibernate-testing/src/main/java/org/hibernate/testing/orm/junit/EntityManagerFactoryExtension.java b/hibernate-testing/src/main/java/org/hibernate/testing/orm/junit/EntityManagerFactoryExtension.java index 1819378f5e..a837981d04 100644 --- a/hibernate-testing/src/main/java/org/hibernate/testing/orm/junit/EntityManagerFactoryExtension.java +++ b/hibernate-testing/src/main/java/org/hibernate/testing/orm/junit/EntityManagerFactoryExtension.java @@ -34,7 +34,6 @@ import org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.ActionGroup import org.hibernate.testing.jdbc.SharedDriverManagerConnectionProviderImpl; import org.hibernate.testing.orm.domain.DomainModelDescriptor; import org.hibernate.testing.orm.domain.StandardDomainModel; -import org.hibernate.testing.orm.jpa.NonStringValueSettingProvider; import org.hibernate.testing.orm.jpa.PersistenceUnitInfoImpl; import org.junit.jupiter.api.extension.AfterAllCallback; import org.junit.jupiter.api.extension.ExtensionContext; @@ -176,16 +175,14 @@ public class EntityManagerFactoryExtension integrationSettings.put( setting.name(), setting.value() ); } - if ( emfAnn.nonStringValueSettingProviders().length > 0 ) { - for ( int i = 0; i < emfAnn.nonStringValueSettingProviders().length; i++ ) { - final Class _class = emfAnn.nonStringValueSettingProviders()[i]; - try { - NonStringValueSettingProvider valueProvider = _class.newInstance(); - integrationSettings.put( valueProvider.getKey(), valueProvider.getValue() ); - } - catch (Exception e) { - log.error( "Error obtaining special value for " + _class.getName(), e ); - } + for ( SettingProvider providerAnn : emfAnn.settingProviders() ) { + final Class> providerImpl = providerAnn.provider(); + try { + final SettingProvider.Provider provider = providerImpl.getConstructor().newInstance(); + integrationSettings.put( providerAnn.settingName(), provider.getSetting() ); + } + catch (Exception e) { + log.error( "Error obtaining setting provider for " + providerImpl.getName(), e ); } } diff --git a/hibernate-testing/src/main/java/org/hibernate/testing/orm/junit/Jpa.java b/hibernate-testing/src/main/java/org/hibernate/testing/orm/junit/Jpa.java index 06a3aa2fcb..68e7aeb187 100644 --- a/hibernate-testing/src/main/java/org/hibernate/testing/orm/junit/Jpa.java +++ b/hibernate-testing/src/main/java/org/hibernate/testing/orm/junit/Jpa.java @@ -21,7 +21,6 @@ import org.hibernate.resource.jdbc.spi.StatementInspector; import org.hibernate.testing.orm.domain.DomainModelDescriptor; import org.hibernate.testing.orm.domain.StandardDomainModel; -import org.hibernate.testing.orm.jpa.NonStringValueSettingProvider; import org.junit.jupiter.api.TestInstance; import org.junit.jupiter.api.extension.ExtendWith; @@ -48,8 +47,6 @@ public @interface Jpa { */ Setting[] integrationSettings() default {}; - Class[] nonStringValueSettingProviders() default {}; - // todo : multiple persistence units? /** @@ -57,6 +54,8 @@ public @interface Jpa { */ Setting[] properties() default {}; + SettingProvider[] settingProviders() default {}; + boolean generateStatistics() default false; boolean exportSchema() default true;