mirror of
https://github.com/hibernate/hibernate-orm
synced 2025-02-16 16:15:06 +00:00
Enable a SettingProvider[] in @Jpa and refactor away the NonStringValueSettingProvider class
Signed-off-by: Jan Schatteman <jschatte@redhat.com>
This commit is contained in:
parent
f935d2b8e1
commit
c4401452dd
@ -12,12 +12,14 @@
|
||||
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 @@
|
||||
@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 {
|
||||
|
||||
|
@ -11,12 +11,14 @@
|
||||
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 @@
|
||||
@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 {
|
||||
|
||||
|
@ -12,7 +12,6 @@
|
||||
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.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 @@
|
||||
Cat.class,
|
||||
Kitten.class
|
||||
},
|
||||
nonStringValueSettingProviders = { NotSerializableClassSettingValueProvider.class }
|
||||
settingProviders = {
|
||||
@SettingProvider(
|
||||
settingName = "BaseEntityManagerFunctionalTestCase.getConfig_addedNotSerializableObject",
|
||||
provider = NotSerializableClassSettingProvider.class)
|
||||
}
|
||||
)
|
||||
public class EntityManagerSerializationTest {
|
||||
@Test
|
||||
|
@ -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 <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
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<NotSerializableClass> {
|
||||
@Override
|
||||
public NotSerializableClass getSetting() {
|
||||
return new NotSerializableClass();
|
||||
}
|
||||
}
|
@ -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 <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
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();
|
||||
}
|
||||
}
|
@ -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 <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
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 );
|
||||
}
|
||||
}
|
@ -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<String> {
|
||||
@Override
|
||||
public String getKey() {
|
||||
return EntityManagerFactoryBuilderImpl.INTEGRATOR_PROVIDER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getValue() {
|
||||
public String getSetting() {
|
||||
return DtoIntegratorProvider.class.getName();
|
||||
}
|
||||
}
|
||||
|
@ -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<DtoIntegratorProvider> {
|
||||
@Override
|
||||
public String getKey() {
|
||||
return EntityManagerFactoryBuilderImpl.INTEGRATOR_PROVIDER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getValue() {
|
||||
public DtoIntegratorProvider getSetting() {
|
||||
return new DtoIntegratorProvider();
|
||||
}
|
||||
}
|
||||
|
@ -8,9 +8,12 @@
|
||||
|
||||
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 @@
|
||||
annotatedClasses = {
|
||||
Person.class
|
||||
},
|
||||
nonStringValueSettingProviders = { DtoIntegratorProviderInstanceSettingProvider.class }
|
||||
settingProviders = {
|
||||
@SettingProvider(
|
||||
settingName = EntityManagerFactoryBuilderImpl.INTEGRATOR_PROVIDER,
|
||||
provider = DtoIntegratorProviderInstanceSettingProvider.class )
|
||||
}
|
||||
)
|
||||
public class IntegrationProviderSettingByObjectTest {
|
||||
|
||||
|
@ -8,9 +8,12 @@
|
||||
|
||||
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 @@
|
||||
annotatedClasses = {
|
||||
Person.class
|
||||
},
|
||||
nonStringValueSettingProviders = { DtoIntegratorProviderClassNameSettingProvider.class }
|
||||
settingProviders = {
|
||||
@SettingProvider(
|
||||
settingName = EntityManagerFactoryBuilderImpl.INTEGRATOR_PROVIDER,
|
||||
provider = DtoIntegratorProviderClassNameSettingProvider.class )
|
||||
}
|
||||
)
|
||||
public class IntegrationProviderSettingByStringTest {
|
||||
|
||||
|
@ -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 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 @@
|
||||
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 static class Child {
|
||||
private Parent parent;
|
||||
}
|
||||
|
||||
public static class EJB3DDMappingProvider extends NonStringValueSettingProvider {
|
||||
public static class EJB3DDMappingProvider implements SettingProvider.Provider<List<String>> {
|
||||
@Override
|
||||
public String getKey() {
|
||||
return AvailableSettings.ORM_XML_FILES;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getValue() {
|
||||
public List<String> getSetting() {
|
||||
return Arrays.asList( "org/hibernate/orm/test/jpa/mapping/orm.xml" );
|
||||
}
|
||||
}
|
||||
|
@ -33,6 +33,7 @@
|
||||
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 @@
|
||||
@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 {
|
||||
|
||||
|
@ -14,6 +14,7 @@
|
||||
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 @@
|
||||
@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 {
|
||||
|
||||
|
@ -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<TestingJtaPlatformImpl> {
|
||||
@Override
|
||||
public String getKey() {
|
||||
return AvailableSettings.JTA_PLATFORM;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getValue() {
|
||||
public TestingJtaPlatformImpl getSetting() {
|
||||
return TestingJtaPlatformImpl.INSTANCE;
|
||||
}
|
||||
}
|
@ -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 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 @@
|
||||
@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 {
|
||||
|
||||
|
@ -26,6 +26,7 @@
|
||||
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 @@
|
||||
|
||||
|
||||
},
|
||||
nonStringValueSettingProviders = { JtaPlatformNonStringValueSettingProvider.class }
|
||||
settingProviders = {
|
||||
@SettingProvider(
|
||||
settingName = AvailableSettings.JTA_PLATFORM,
|
||||
provider = JtaPlatformSettingProvider.class
|
||||
)
|
||||
}
|
||||
)
|
||||
public class SynchronizationTypeTest {
|
||||
|
||||
|
@ -15,6 +15,7 @@
|
||||
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.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 @@
|
||||
@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 {
|
||||
|
||||
|
@ -13,11 +13,13 @@
|
||||
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 @@
|
||||
@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 {
|
||||
|
||||
|
@ -17,13 +17,12 @@
|
||||
|
||||
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 @@ protected void assertAllStatementsAreClosed(List<PreparedStatement> statements)
|
||||
} );
|
||||
}
|
||||
|
||||
public static class ConnectionNonStringValueSettingProvider extends NonStringValueSettingProvider {
|
||||
public static class ConnectionSettingProvider implements SettingProvider.Provider<String> {
|
||||
@Override
|
||||
public String getKey() {
|
||||
return AvailableSettings.CONNECTION_PROVIDER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getValue() {
|
||||
public String getSetting() {
|
||||
return JtaAwareConnectionProviderImpl.class.getName();
|
||||
}
|
||||
}
|
||||
|
@ -21,16 +21,16 @@
|
||||
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 @@
|
||||
@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 @@ private void assertStatementsListIsCleared() {
|
||||
);
|
||||
}
|
||||
|
||||
public static class BatchBuilderNonStringValueSettingProvider extends NonStringValueSettingProvider {
|
||||
public static class BatchBuilderSettingProvider implements SettingProvider.Provider<String> {
|
||||
@Override
|
||||
public String getKey() {
|
||||
return BatchBuilderInitiator.BUILDER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getValue() {
|
||||
public String getSetting() {
|
||||
return TestBatchBuilder.class.getName();
|
||||
}
|
||||
}
|
||||
|
@ -20,16 +20,16 @@
|
||||
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 @@
|
||||
@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 @@ private void assertStatementsListIsCleared() {
|
||||
);
|
||||
}
|
||||
|
||||
public static class BatchBuilderNonStringValueSettingProvider extends NonStringValueSettingProvider {
|
||||
public static class BatchBuilderSettingProvider implements SettingProvider.Provider<String> {
|
||||
@Override
|
||||
public String getKey() {
|
||||
return BatchBuilderInitiator.BUILDER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getValue() {
|
||||
public String getSetting() {
|
||||
return TestBatchBuilder.class.getName();
|
||||
}
|
||||
}
|
||||
|
@ -13,9 +13,9 @@
|
||||
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 @@
|
||||
*/
|
||||
@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 void testXmlMappingWithCacheable(EntityManagerFactoryScope scope) {
|
||||
Assertions.assertTrue(entityPersister.canWriteToCache());
|
||||
}
|
||||
|
||||
public static class SharedCacheModeProvider extends NonStringValueSettingProvider {
|
||||
public static class SharedCacheModeProvider implements SettingProvider.Provider<SharedCacheMode> {
|
||||
@Override
|
||||
public String getKey() {
|
||||
return AvailableSettings.JPA_SHARED_CACHE_MODE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getValue() {
|
||||
public SharedCacheMode getSetting() {
|
||||
return SharedCacheMode.ENABLE_SELECTIVE;
|
||||
}
|
||||
}
|
||||
|
@ -18,9 +18,9 @@
|
||||
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 @@
|
||||
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<Class> {
|
||||
@Override
|
||||
public String getKey() {
|
||||
return AvailableSettings.STATEMENT_INSPECTOR;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getValue() {
|
||||
public Class getSetting() {
|
||||
return SQLStatementInspector.class;
|
||||
}
|
||||
}
|
||||
|
@ -14,6 +14,6 @@
|
||||
public class PreparedStatementSpyConnectionProviderSettingProvider implements SettingProvider.Provider<PreparedStatementSpyConnectionProvider> {
|
||||
@Override
|
||||
public PreparedStatementSpyConnectionProvider getSetting() {
|
||||
return new PreparedStatementSpyConnectionProvider( true, false );
|
||||
return new PreparedStatementSpyConnectionProvider( false, false );
|
||||
}
|
||||
}
|
||||
|
@ -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 <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.testing.orm.jpa;
|
||||
|
||||
/**
|
||||
* @author Jan Schatteman
|
||||
*/
|
||||
public abstract class NonStringValueSettingProvider {
|
||||
public abstract String getKey();
|
||||
public abstract Object getValue();
|
||||
}
|
@ -34,7 +34,6 @@
|
||||
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 static EntityManagerFactoryScope findEntityManagerFactoryScope(
|
||||
integrationSettings.put( setting.name(), setting.value() );
|
||||
}
|
||||
|
||||
if ( emfAnn.nonStringValueSettingProviders().length > 0 ) {
|
||||
for ( int i = 0; i < emfAnn.nonStringValueSettingProviders().length; i++ ) {
|
||||
final Class<? extends NonStringValueSettingProvider> _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<? extends SettingProvider.Provider<?>> 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 );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -21,7 +21,6 @@
|
||||
|
||||
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 @@
|
||||
*/
|
||||
Setting[] integrationSettings() default {};
|
||||
|
||||
Class<? extends NonStringValueSettingProvider>[] nonStringValueSettingProviders() default {};
|
||||
|
||||
// todo : multiple persistence units?
|
||||
|
||||
/**
|
||||
@ -57,6 +54,8 @@
|
||||
*/
|
||||
Setting[] properties() default {};
|
||||
|
||||
SettingProvider[] settingProviders() default {};
|
||||
|
||||
boolean generateStatistics() default false;
|
||||
boolean exportSchema() default true;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user