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 java.util.Map;
|
||||||
import org.hibernate.cfg.AvailableSettings;
|
import org.hibernate.cfg.AvailableSettings;
|
||||||
import org.hibernate.orm.test.jpa.Wallet;
|
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.DialectFeatureChecks;
|
||||||
import org.hibernate.testing.orm.junit.EntityManagerFactoryScope;
|
import org.hibernate.testing.orm.junit.EntityManagerFactoryScope;
|
||||||
import org.hibernate.testing.orm.junit.Jpa;
|
import org.hibernate.testing.orm.junit.Jpa;
|
||||||
import org.hibernate.testing.orm.junit.RequiresDialectFeature;
|
import org.hibernate.testing.orm.junit.RequiresDialectFeature;
|
||||||
import org.hibernate.testing.orm.junit.Setting;
|
import org.hibernate.testing.orm.junit.Setting;
|
||||||
import org.hibernate.testing.orm.jdbc.PreparedStatementSpyConnectionProvider;
|
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.AfterAll;
|
||||||
import org.junit.jupiter.api.BeforeAll;
|
import org.junit.jupiter.api.BeforeAll;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
@ -33,7 +35,11 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
@Jpa(
|
@Jpa(
|
||||||
annotatedClasses = { Wallet.class },
|
annotatedClasses = { Wallet.class },
|
||||||
integrationSettings = { @Setting( name = AvailableSettings.DISCARD_PC_ON_CLOSE, value = "false") },
|
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 {
|
public class DisableDiscardPersistenceContextOnCloseTest {
|
||||||
|
|
||||||
|
|
|
@ -11,12 +11,14 @@ import java.util.Map;
|
||||||
import org.hibernate.cfg.AvailableSettings;
|
import org.hibernate.cfg.AvailableSettings;
|
||||||
import org.hibernate.orm.test.jpa.Wallet;
|
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.DialectFeatureChecks;
|
||||||
import org.hibernate.testing.orm.junit.RequiresDialectFeature;
|
import org.hibernate.testing.orm.junit.RequiresDialectFeature;
|
||||||
import org.hibernate.testing.orm.junit.EntityManagerFactoryScope;
|
import org.hibernate.testing.orm.junit.EntityManagerFactoryScope;
|
||||||
import org.hibernate.testing.orm.junit.Jpa;
|
import org.hibernate.testing.orm.junit.Jpa;
|
||||||
import org.hibernate.testing.orm.junit.Setting;
|
import org.hibernate.testing.orm.junit.Setting;
|
||||||
import org.hibernate.testing.orm.jdbc.PreparedStatementSpyConnectionProvider;
|
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.BeforeAll;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
@ -31,7 +33,11 @@ import static org.junit.jupiter.api.Assertions.fail;
|
||||||
@Jpa(
|
@Jpa(
|
||||||
annotatedClasses = { Wallet.class },
|
annotatedClasses = { Wallet.class },
|
||||||
integrationSettings = { @Setting(name = AvailableSettings.DISCARD_PC_ON_CLOSE, value = "true") },
|
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 {
|
public class EnableDiscardPersistenceContextOnCloseTest {
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,6 @@ import java.io.ObjectInputStream;
|
||||||
import java.io.ObjectOutput;
|
import java.io.ObjectOutput;
|
||||||
import java.io.ObjectOutputStream;
|
import java.io.ObjectOutputStream;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import jakarta.persistence.EntityManager;
|
|
||||||
|
|
||||||
import org.hibernate.Session;
|
import org.hibernate.Session;
|
||||||
import org.hibernate.orm.test.jpa.Cat;
|
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.EntityManagerFactoryScope;
|
||||||
import org.hibernate.testing.orm.junit.Jpa;
|
import org.hibernate.testing.orm.junit.Jpa;
|
||||||
|
import org.hibernate.testing.orm.junit.SettingProvider;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import jakarta.persistence.EntityManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Emmanuel Bernard
|
* @author Emmanuel Bernard
|
||||||
* @author Scott Marlow
|
* @author Scott Marlow
|
||||||
|
@ -38,7 +39,11 @@ import org.junit.jupiter.api.Test;
|
||||||
Cat.class,
|
Cat.class,
|
||||||
Kitten.class
|
Kitten.class
|
||||||
},
|
},
|
||||||
nonStringValueSettingProviders = { NotSerializableClassSettingValueProvider.class }
|
settingProviders = {
|
||||||
|
@SettingProvider(
|
||||||
|
settingName = "BaseEntityManagerFunctionalTestCase.getConfig_addedNotSerializableObject",
|
||||||
|
provider = NotSerializableClassSettingProvider.class)
|
||||||
|
}
|
||||||
)
|
)
|
||||||
public class EntityManagerSerializationTest {
|
public class EntityManagerSerializationTest {
|
||||||
@Test
|
@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;
|
package org.hibernate.orm.test.jpa.integrationprovider;
|
||||||
|
|
||||||
import org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl;
|
import org.hibernate.testing.orm.junit.SettingProvider;
|
||||||
|
|
||||||
import org.hibernate.testing.orm.jpa.NonStringValueSettingProvider;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Jan Schatteman
|
* @author Jan Schatteman
|
||||||
*/
|
*/
|
||||||
public class DtoIntegratorProviderClassNameSettingProvider extends NonStringValueSettingProvider {
|
public class DtoIntegratorProviderClassNameSettingProvider implements SettingProvider.Provider<String> {
|
||||||
@Override
|
@Override
|
||||||
public String getKey() {
|
public String getSetting() {
|
||||||
return EntityManagerFactoryBuilderImpl.INTEGRATOR_PROVIDER;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getValue() {
|
|
||||||
return DtoIntegratorProvider.class.getName();
|
return DtoIntegratorProvider.class.getName();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,21 +6,14 @@
|
||||||
*/
|
*/
|
||||||
package org.hibernate.orm.test.jpa.integrationprovider;
|
package org.hibernate.orm.test.jpa.integrationprovider;
|
||||||
|
|
||||||
import org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl;
|
import org.hibernate.testing.orm.junit.SettingProvider;
|
||||||
|
|
||||||
import org.hibernate.testing.orm.jpa.NonStringValueSettingProvider;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Jan Schatteman
|
* @author Jan Schatteman
|
||||||
*/
|
*/
|
||||||
public class DtoIntegratorProviderInstanceSettingProvider extends NonStringValueSettingProvider {
|
public class DtoIntegratorProviderInstanceSettingProvider implements SettingProvider.Provider<DtoIntegratorProvider> {
|
||||||
@Override
|
@Override
|
||||||
public String getKey() {
|
public DtoIntegratorProvider getSetting() {
|
||||||
return EntityManagerFactoryBuilderImpl.INTEGRATOR_PROVIDER;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getValue() {
|
|
||||||
return new DtoIntegratorProvider();
|
return new DtoIntegratorProvider();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,9 +8,12 @@ package org.hibernate.orm.test.jpa.integrationprovider;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl;
|
||||||
|
|
||||||
import org.hibernate.testing.TestForIssue;
|
import org.hibernate.testing.TestForIssue;
|
||||||
import org.hibernate.testing.orm.junit.EntityManagerFactoryScope;
|
import org.hibernate.testing.orm.junit.EntityManagerFactoryScope;
|
||||||
import org.hibernate.testing.orm.junit.Jpa;
|
import org.hibernate.testing.orm.junit.Jpa;
|
||||||
|
import org.hibernate.testing.orm.junit.SettingProvider;
|
||||||
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
@ -23,7 +26,11 @@ import org.junit.jupiter.api.Test;
|
||||||
annotatedClasses = {
|
annotatedClasses = {
|
||||||
Person.class
|
Person.class
|
||||||
},
|
},
|
||||||
nonStringValueSettingProviders = { DtoIntegratorProviderInstanceSettingProvider.class }
|
settingProviders = {
|
||||||
|
@SettingProvider(
|
||||||
|
settingName = EntityManagerFactoryBuilderImpl.INTEGRATOR_PROVIDER,
|
||||||
|
provider = DtoIntegratorProviderInstanceSettingProvider.class )
|
||||||
|
}
|
||||||
)
|
)
|
||||||
public class IntegrationProviderSettingByObjectTest {
|
public class IntegrationProviderSettingByObjectTest {
|
||||||
|
|
||||||
|
|
|
@ -8,9 +8,12 @@ package org.hibernate.orm.test.jpa.integrationprovider;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl;
|
||||||
|
|
||||||
import org.hibernate.testing.TestForIssue;
|
import org.hibernate.testing.TestForIssue;
|
||||||
import org.hibernate.testing.orm.junit.EntityManagerFactoryScope;
|
import org.hibernate.testing.orm.junit.EntityManagerFactoryScope;
|
||||||
import org.hibernate.testing.orm.junit.Jpa;
|
import org.hibernate.testing.orm.junit.Jpa;
|
||||||
|
import org.hibernate.testing.orm.junit.SettingProvider;
|
||||||
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
@ -22,7 +25,11 @@ import org.junit.jupiter.api.Test;
|
||||||
annotatedClasses = {
|
annotatedClasses = {
|
||||||
Person.class
|
Person.class
|
||||||
},
|
},
|
||||||
nonStringValueSettingProviders = { DtoIntegratorProviderClassNameSettingProvider.class }
|
settingProviders = {
|
||||||
|
@SettingProvider(
|
||||||
|
settingName = EntityManagerFactoryBuilderImpl.INTEGRATOR_PROVIDER,
|
||||||
|
provider = DtoIntegratorProviderClassNameSettingProvider.class )
|
||||||
|
}
|
||||||
)
|
)
|
||||||
public class IntegrationProviderSettingByStringTest {
|
public class IntegrationProviderSettingByStringTest {
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,8 @@
|
||||||
package org.hibernate.orm.test.jpa.mapping;
|
package org.hibernate.orm.test.jpa.mapping;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import jakarta.persistence.Entity;
|
import jakarta.persistence.Entity;
|
||||||
import jakarta.persistence.GeneratedValue;
|
import jakarta.persistence.GeneratedValue;
|
||||||
import jakarta.persistence.Id;
|
import jakarta.persistence.Id;
|
||||||
|
@ -15,9 +17,9 @@ import jakarta.persistence.Table;
|
||||||
|
|
||||||
import org.hibernate.cfg.AvailableSettings;
|
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.EntityManagerFactoryScope;
|
||||||
import org.hibernate.testing.orm.junit.Jpa;
|
import org.hibernate.testing.orm.junit.Jpa;
|
||||||
|
import org.hibernate.testing.orm.junit.SettingProvider;
|
||||||
|
|
||||||
import org.junit.jupiter.api.AfterEach;
|
import org.junit.jupiter.api.AfterEach;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
@ -31,7 +33,11 @@ import org.junit.jupiter.api.Test;
|
||||||
DefaultCascadeTest.Child.class
|
DefaultCascadeTest.Child.class
|
||||||
},
|
},
|
||||||
// using 'xmlMappings = { "org/hibernate/orm/test/jpa/mapping/orm.xml" }' also works
|
// 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 {
|
public class DefaultCascadeTest {
|
||||||
|
|
||||||
|
@ -79,14 +85,9 @@ public class DefaultCascadeTest {
|
||||||
private Parent parent;
|
private Parent parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class EJB3DDMappingProvider extends NonStringValueSettingProvider {
|
public static class EJB3DDMappingProvider implements SettingProvider.Provider<List<String>> {
|
||||||
@Override
|
@Override
|
||||||
public String getKey() {
|
public List<String> getSetting() {
|
||||||
return AvailableSettings.ORM_XML_FILES;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getValue() {
|
|
||||||
return Arrays.asList( "org/hibernate/orm/test/jpa/mapping/orm.xml" );
|
return Arrays.asList( "org/hibernate/orm/test/jpa/mapping/orm.xml" );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,6 +33,7 @@ import org.hibernate.testing.jta.TestingJtaPlatformImpl;
|
||||||
import org.hibernate.testing.orm.junit.EntityManagerFactoryScope;
|
import org.hibernate.testing.orm.junit.EntityManagerFactoryScope;
|
||||||
import org.hibernate.testing.orm.junit.Jpa;
|
import org.hibernate.testing.orm.junit.Jpa;
|
||||||
import org.hibernate.testing.orm.junit.Setting;
|
import org.hibernate.testing.orm.junit.Setting;
|
||||||
|
import org.hibernate.testing.orm.junit.SettingProvider;
|
||||||
import org.junit.jupiter.api.AfterEach;
|
import org.junit.jupiter.api.AfterEach;
|
||||||
import org.junit.jupiter.api.Test;
|
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_TYPE, value = "JTA"),
|
||||||
@Setting(name = AvailableSettings.JPA_TRANSACTION_COMPLIANCE, value = "true")
|
@Setting(name = AvailableSettings.JPA_TRANSACTION_COMPLIANCE, value = "true")
|
||||||
},
|
},
|
||||||
nonStringValueSettingProviders = { JtaPlatformNonStringValueSettingProvider.class }
|
settingProviders = {
|
||||||
|
@SettingProvider(
|
||||||
|
settingName = AvailableSettings.JTA_PLATFORM,
|
||||||
|
provider = JtaPlatformSettingProvider.class
|
||||||
|
)
|
||||||
|
}
|
||||||
)
|
)
|
||||||
public class CloseEntityManagerWithActiveTransactionTest {
|
public class CloseEntityManagerWithActiveTransactionTest {
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,7 @@ import org.hibernate.testing.TestForIssue;
|
||||||
import org.hibernate.testing.orm.junit.EntityManagerFactoryScope;
|
import org.hibernate.testing.orm.junit.EntityManagerFactoryScope;
|
||||||
import org.hibernate.testing.orm.junit.Jpa;
|
import org.hibernate.testing.orm.junit.Jpa;
|
||||||
import org.hibernate.testing.orm.junit.Setting;
|
import org.hibernate.testing.orm.junit.Setting;
|
||||||
|
import org.hibernate.testing.orm.junit.SettingProvider;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
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.CONNECTION_PROVIDER, value = "org.hibernate.testing.jta.JtaAwareConnectionProviderImpl"),
|
||||||
@Setting( name = AvailableSettings.JPA_TRANSACTION_COMPLIANCE, value = "true")
|
@Setting( name = AvailableSettings.JPA_TRANSACTION_COMPLIANCE, value = "true")
|
||||||
},
|
},
|
||||||
nonStringValueSettingProviders = { JtaPlatformNonStringValueSettingProvider.class }
|
settingProviders = {
|
||||||
|
@SettingProvider(
|
||||||
|
settingName = AvailableSettings.JTA_PLATFORM,
|
||||||
|
provider = JtaPlatformSettingProvider.class
|
||||||
|
)
|
||||||
|
}
|
||||||
)
|
)
|
||||||
public class JtaGetTransactionThrowsExceptionTest {
|
public class JtaGetTransactionThrowsExceptionTest {
|
||||||
|
|
||||||
|
|
|
@ -6,22 +6,15 @@
|
||||||
*/
|
*/
|
||||||
package org.hibernate.orm.test.jpa.transaction;
|
package org.hibernate.orm.test.jpa.transaction;
|
||||||
|
|
||||||
import org.hibernate.cfg.AvailableSettings;
|
|
||||||
|
|
||||||
import org.hibernate.testing.jta.TestingJtaPlatformImpl;
|
import org.hibernate.testing.jta.TestingJtaPlatformImpl;
|
||||||
import org.hibernate.testing.orm.jpa.NonStringValueSettingProvider;
|
import org.hibernate.testing.orm.junit.SettingProvider;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Jan Schatteman
|
* @author Jan Schatteman
|
||||||
*/
|
*/
|
||||||
public class JtaPlatformNonStringValueSettingProvider extends NonStringValueSettingProvider {
|
public class JtaPlatformSettingProvider implements SettingProvider.Provider<TestingJtaPlatformImpl> {
|
||||||
@Override
|
@Override
|
||||||
public String getKey() {
|
public TestingJtaPlatformImpl getSetting() {
|
||||||
return AvailableSettings.JTA_PLATFORM;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getValue() {
|
|
||||||
return TestingJtaPlatformImpl.INSTANCE;
|
return TestingJtaPlatformImpl.INSTANCE;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -7,6 +7,9 @@
|
||||||
package org.hibernate.orm.test.jpa.transaction;
|
package org.hibernate.orm.test.jpa.transaction;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.hibernate.cfg.AvailableSettings;
|
||||||
|
|
||||||
import jakarta.persistence.Entity;
|
import jakarta.persistence.Entity;
|
||||||
import jakarta.persistence.EntityTransaction;
|
import jakarta.persistence.EntityTransaction;
|
||||||
import jakarta.persistence.GeneratedValue;
|
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.EntityManagerFactoryScope;
|
||||||
import org.hibernate.testing.orm.junit.Jpa;
|
import org.hibernate.testing.orm.junit.Jpa;
|
||||||
import org.hibernate.testing.orm.junit.Setting;
|
import org.hibernate.testing.orm.junit.Setting;
|
||||||
|
import org.hibernate.testing.orm.junit.SettingProvider;
|
||||||
|
|
||||||
import org.junit.jupiter.api.Test;
|
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.CONNECTION_PROVIDER, value = "org.hibernate.testing.jta.JtaAwareConnectionProviderImpl"),
|
||||||
@Setting(name = org.hibernate.cfg.AvailableSettings.JPA_TRANSACTION_TYPE, value = "JTA")
|
@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 {
|
public class JtaReusingEntityTransactionTest {
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,7 @@ import org.hibernate.testing.orm.junit.EntityManagerFactoryScope;
|
||||||
import org.hibernate.testing.orm.junit.ExtraAssertions;
|
import org.hibernate.testing.orm.junit.ExtraAssertions;
|
||||||
import org.hibernate.testing.orm.junit.Jpa;
|
import org.hibernate.testing.orm.junit.Jpa;
|
||||||
import org.hibernate.testing.orm.junit.Setting;
|
import org.hibernate.testing.orm.junit.Setting;
|
||||||
|
import org.hibernate.testing.orm.junit.SettingProvider;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
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 {
|
public class SynchronizationTypeTest {
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,7 @@ import jakarta.transaction.Status;
|
||||||
import jakarta.transaction.TransactionManager;
|
import jakarta.transaction.TransactionManager;
|
||||||
|
|
||||||
import org.hibernate.HibernateException;
|
import org.hibernate.HibernateException;
|
||||||
|
import org.hibernate.cfg.AvailableSettings;
|
||||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||||
import org.hibernate.engine.transaction.internal.jta.JtaStatusHelper;
|
import org.hibernate.engine.transaction.internal.jta.JtaStatusHelper;
|
||||||
import org.hibernate.internal.SessionImpl;
|
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.ExtraAssertions;
|
||||||
import org.hibernate.testing.orm.junit.Jpa;
|
import org.hibernate.testing.orm.junit.Jpa;
|
||||||
import org.hibernate.testing.orm.junit.Setting;
|
import org.hibernate.testing.orm.junit.Setting;
|
||||||
|
import org.hibernate.testing.orm.junit.SettingProvider;
|
||||||
import org.junit.jupiter.api.Assertions;
|
import org.junit.jupiter.api.Assertions;
|
||||||
import org.junit.jupiter.api.Test;
|
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.CONNECTION_PROVIDER, value = "org.hibernate.testing.jta.JtaAwareConnectionProviderImpl"),
|
||||||
@Setting(name = org.hibernate.cfg.AvailableSettings.JPA_TRANSACTION_TYPE, value = "JTA")
|
@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 {
|
public class TransactionJoiningTest {
|
||||||
|
|
||||||
|
|
|
@ -13,11 +13,13 @@ import jakarta.transaction.SystemException;
|
||||||
import jakarta.transaction.TransactionManager;
|
import jakarta.transaction.TransactionManager;
|
||||||
|
|
||||||
import org.hibernate.HibernateException;
|
import org.hibernate.HibernateException;
|
||||||
|
import org.hibernate.cfg.AvailableSettings;
|
||||||
|
|
||||||
import org.hibernate.testing.jta.TestingJtaPlatformImpl;
|
import org.hibernate.testing.jta.TestingJtaPlatformImpl;
|
||||||
import org.hibernate.testing.orm.junit.EntityManagerFactoryScope;
|
import org.hibernate.testing.orm.junit.EntityManagerFactoryScope;
|
||||||
import org.hibernate.testing.orm.junit.Jpa;
|
import org.hibernate.testing.orm.junit.Jpa;
|
||||||
import org.hibernate.testing.orm.junit.Setting;
|
import org.hibernate.testing.orm.junit.Setting;
|
||||||
|
import org.hibernate.testing.orm.junit.SettingProvider;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.fail;
|
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.CONNECTION_PROVIDER, value = "org.hibernate.testing.jta.JtaAwareConnectionProviderImpl"),
|
||||||
@Setting(name = org.hibernate.cfg.AvailableSettings.JPA_TRANSACTION_TYPE, value = "JTA")
|
@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 {
|
public class TransactionRolledBackInDifferentThreadTest {
|
||||||
|
|
||||||
|
|
|
@ -17,13 +17,12 @@ import jakarta.persistence.Table;
|
||||||
|
|
||||||
import org.hibernate.annotations.GenericGenerator;
|
import org.hibernate.annotations.GenericGenerator;
|
||||||
import org.hibernate.annotations.Parameter;
|
import org.hibernate.annotations.Parameter;
|
||||||
import org.hibernate.cfg.AvailableSettings;
|
|
||||||
import org.hibernate.internal.HEMLogging;
|
import org.hibernate.internal.HEMLogging;
|
||||||
import org.hibernate.jpa.boot.spi.ProviderChecker;
|
import org.hibernate.jpa.boot.spi.ProviderChecker;
|
||||||
|
|
||||||
import org.hibernate.testing.jta.JtaAwareConnectionProviderImpl;
|
import org.hibernate.testing.jta.JtaAwareConnectionProviderImpl;
|
||||||
import org.hibernate.testing.logger.Triggerable;
|
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.hibernate.testing.orm.logger.LoggerInspectionExtension;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.jupiter.api.extension.RegisterExtension;
|
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<String> {
|
||||||
@Override
|
@Override
|
||||||
public String getKey() {
|
public String getSetting() {
|
||||||
return AvailableSettings.CONNECTION_PROVIDER;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getValue() {
|
|
||||||
return JtaAwareConnectionProviderImpl.class.getName();
|
return JtaAwareConnectionProviderImpl.class.getName();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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.Batch;
|
||||||
import org.hibernate.engine.jdbc.batch.spi.BatchKey;
|
import org.hibernate.engine.jdbc.batch.spi.BatchKey;
|
||||||
import org.hibernate.engine.jdbc.spi.JdbcCoordinator;
|
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.TestForIssue;
|
||||||
import org.hibernate.testing.jta.TestingJtaPlatformImpl;
|
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.DialectFeatureChecks;
|
||||||
import org.hibernate.testing.orm.junit.EntityManagerFactoryScope;
|
import org.hibernate.testing.orm.junit.EntityManagerFactoryScope;
|
||||||
import org.hibernate.testing.orm.junit.Jpa;
|
import org.hibernate.testing.orm.junit.Jpa;
|
||||||
import org.hibernate.testing.orm.junit.RequiresDialectFeature;
|
import org.hibernate.testing.orm.junit.RequiresDialectFeature;
|
||||||
import org.hibernate.testing.orm.junit.Setting;
|
import org.hibernate.testing.orm.junit.Setting;
|
||||||
|
import org.hibernate.testing.orm.junit.SettingProvider;
|
||||||
|
|
||||||
import org.junit.jupiter.api.Test;
|
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.JPA_TRANSACTION_COMPLIANCE, value = "true"),
|
||||||
@Setting(name = AvailableSettings.STATEMENT_BATCH_SIZE, value = "50")
|
@Setting(name = AvailableSettings.STATEMENT_BATCH_SIZE, value = "50")
|
||||||
},
|
},
|
||||||
nonStringValueSettingProviders = {
|
settingProviders = {
|
||||||
JtaPlatformNonStringValueSettingProvider.class,
|
@SettingProvider(
|
||||||
AbstractJtaBatchTest.ConnectionNonStringValueSettingProvider.class,
|
settingName = AvailableSettings.CONNECTION_PROVIDER,
|
||||||
JtaWithFailingBatchTest.BatchBuilderNonStringValueSettingProvider.class
|
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 {
|
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<String> {
|
||||||
@Override
|
@Override
|
||||||
public String getKey() {
|
public String getSetting() {
|
||||||
return BatchBuilderInitiator.BUILDER;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getValue() {
|
|
||||||
return TestBatchBuilder.class.getName();
|
return TestBatchBuilder.class.getName();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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.Batch;
|
||||||
import org.hibernate.engine.jdbc.batch.spi.BatchKey;
|
import org.hibernate.engine.jdbc.batch.spi.BatchKey;
|
||||||
import org.hibernate.engine.jdbc.spi.JdbcCoordinator;
|
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.TestForIssue;
|
||||||
import org.hibernate.testing.jta.TestingJtaPlatformImpl;
|
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.DialectFeatureChecks;
|
||||||
import org.hibernate.testing.orm.junit.EntityManagerFactoryScope;
|
import org.hibernate.testing.orm.junit.EntityManagerFactoryScope;
|
||||||
import org.hibernate.testing.orm.junit.Jpa;
|
import org.hibernate.testing.orm.junit.Jpa;
|
||||||
import org.hibernate.testing.orm.junit.RequiresDialectFeature;
|
import org.hibernate.testing.orm.junit.RequiresDialectFeature;
|
||||||
import org.hibernate.testing.orm.junit.Setting;
|
import org.hibernate.testing.orm.junit.Setting;
|
||||||
|
import org.hibernate.testing.orm.junit.SettingProvider;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import static org.hamcrest.MatcherAssert.assertThat;
|
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.JPA_TRANSACTION_COMPLIANCE, value = "true"),
|
||||||
@Setting(name = AvailableSettings.STATEMENT_BATCH_SIZE, value = "50")
|
@Setting(name = AvailableSettings.STATEMENT_BATCH_SIZE, value = "50")
|
||||||
},
|
},
|
||||||
nonStringValueSettingProviders = {
|
settingProviders = {
|
||||||
JtaPlatformNonStringValueSettingProvider.class,
|
@SettingProvider(
|
||||||
AbstractJtaBatchTest.ConnectionNonStringValueSettingProvider.class,
|
settingName = AvailableSettings.CONNECTION_PROVIDER,
|
||||||
JtaWithStatementsBatchTest.BatchBuilderNonStringValueSettingProvider.class
|
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 {
|
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<String> {
|
||||||
@Override
|
@Override
|
||||||
public String getKey() {
|
public String getSetting() {
|
||||||
return BatchBuilderInitiator.BUILDER;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getValue() {
|
|
||||||
return TestBatchBuilder.class.getName();
|
return TestBatchBuilder.class.getName();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,9 +13,9 @@ import org.hibernate.cfg.AvailableSettings;
|
||||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||||
import org.hibernate.persister.entity.EntityPersister;
|
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.EntityManagerFactoryScope;
|
||||||
import org.hibernate.testing.orm.junit.Jpa;
|
import org.hibernate.testing.orm.junit.Jpa;
|
||||||
|
import org.hibernate.testing.orm.junit.SettingProvider;
|
||||||
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.jupiter.api.Assertions;
|
import org.junit.jupiter.api.Assertions;
|
||||||
|
@ -25,7 +25,12 @@ import org.junit.jupiter.api.Assertions;
|
||||||
*/
|
*/
|
||||||
@Jpa(
|
@Jpa(
|
||||||
xmlMappings = {"org/hibernate/orm/test/jpa/xml/orm.xml", "org/hibernate/orm/test/jpa/xml/orm2.xml"},
|
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 {
|
public class XmlTest {
|
||||||
@Test
|
@Test
|
||||||
|
@ -43,14 +48,9 @@ public class XmlTest {
|
||||||
Assertions.assertTrue(entityPersister.canWriteToCache());
|
Assertions.assertTrue(entityPersister.canWriteToCache());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class SharedCacheModeProvider extends NonStringValueSettingProvider {
|
public static class SharedCacheModeProvider implements SettingProvider.Provider<SharedCacheMode> {
|
||||||
@Override
|
@Override
|
||||||
public String getKey() {
|
public SharedCacheMode getSetting() {
|
||||||
return AvailableSettings.JPA_SHARED_CACHE_MODE;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getValue() {
|
|
||||||
return SharedCacheMode.ENABLE_SELECTIVE;
|
return SharedCacheMode.ENABLE_SELECTIVE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,9 +18,9 @@ import org.hibernate.SessionFactory;
|
||||||
import org.hibernate.cfg.AvailableSettings;
|
import org.hibernate.cfg.AvailableSettings;
|
||||||
|
|
||||||
import org.hibernate.testing.jdbc.SQLStatementInspector;
|
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.EntityManagerFactoryScope;
|
||||||
import org.hibernate.testing.orm.junit.Jpa;
|
import org.hibernate.testing.orm.junit.Jpa;
|
||||||
|
import org.hibernate.testing.orm.junit.SettingProvider;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
@ -34,18 +34,18 @@ import static org.junit.jupiter.api.Assertions.assertSame;
|
||||||
OneToOneMapsIdJoinColumnTest.Person.class,
|
OneToOneMapsIdJoinColumnTest.Person.class,
|
||||||
OneToOneMapsIdJoinColumnTest.PersonDetails.class
|
OneToOneMapsIdJoinColumnTest.PersonDetails.class
|
||||||
},
|
},
|
||||||
nonStringValueSettingProviders = { OneToOneMapsIdJoinColumnTest.SQLStatementInspectorProvider.class }
|
settingProviders = {
|
||||||
|
@SettingProvider(
|
||||||
|
settingName = AvailableSettings.STATEMENT_INSPECTOR,
|
||||||
|
provider = OneToOneMapsIdJoinColumnTest.SQLStatementInspectorProvider.class
|
||||||
|
)
|
||||||
|
}
|
||||||
)
|
)
|
||||||
public class OneToOneMapsIdJoinColumnTest {
|
public class OneToOneMapsIdJoinColumnTest {
|
||||||
|
|
||||||
public static class SQLStatementInspectorProvider extends NonStringValueSettingProvider {
|
public static class SQLStatementInspectorProvider implements SettingProvider.Provider<Class> {
|
||||||
@Override
|
@Override
|
||||||
public String getKey() {
|
public Class getSetting() {
|
||||||
return AvailableSettings.STATEMENT_INSPECTOR;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getValue() {
|
|
||||||
return SQLStatementInspector.class;
|
return SQLStatementInspector.class;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,6 @@ import org.hibernate.testing.orm.junit.SettingProvider;
|
||||||
public class PreparedStatementSpyConnectionProviderSettingProvider implements SettingProvider.Provider<PreparedStatementSpyConnectionProvider> {
|
public class PreparedStatementSpyConnectionProviderSettingProvider implements SettingProvider.Provider<PreparedStatementSpyConnectionProvider> {
|
||||||
@Override
|
@Override
|
||||||
public PreparedStatementSpyConnectionProvider getSetting() {
|
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.tool.schema.spi.SchemaManagementToolCoordinator.ActionGroup
|
||||||
import org.hibernate.testing.jdbc.SharedDriverManagerConnectionProviderImpl;
|
import org.hibernate.testing.jdbc.SharedDriverManagerConnectionProviderImpl;
|
||||||
import org.hibernate.testing.orm.domain.DomainModelDescriptor;
|
import org.hibernate.testing.orm.domain.DomainModelDescriptor;
|
||||||
import org.hibernate.testing.orm.domain.StandardDomainModel;
|
import org.hibernate.testing.orm.domain.StandardDomainModel;
|
||||||
import org.hibernate.testing.orm.jpa.NonStringValueSettingProvider;
|
|
||||||
import org.hibernate.testing.orm.jpa.PersistenceUnitInfoImpl;
|
import org.hibernate.testing.orm.jpa.PersistenceUnitInfoImpl;
|
||||||
import org.junit.jupiter.api.extension.AfterAllCallback;
|
import org.junit.jupiter.api.extension.AfterAllCallback;
|
||||||
import org.junit.jupiter.api.extension.ExtensionContext;
|
import org.junit.jupiter.api.extension.ExtensionContext;
|
||||||
|
@ -176,16 +175,14 @@ public class EntityManagerFactoryExtension
|
||||||
integrationSettings.put( setting.name(), setting.value() );
|
integrationSettings.put( setting.name(), setting.value() );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( emfAnn.nonStringValueSettingProviders().length > 0 ) {
|
for ( SettingProvider providerAnn : emfAnn.settingProviders() ) {
|
||||||
for ( int i = 0; i < emfAnn.nonStringValueSettingProviders().length; i++ ) {
|
final Class<? extends SettingProvider.Provider<?>> providerImpl = providerAnn.provider();
|
||||||
final Class<? extends NonStringValueSettingProvider> _class = emfAnn.nonStringValueSettingProviders()[i];
|
|
||||||
try {
|
try {
|
||||||
NonStringValueSettingProvider valueProvider = _class.newInstance();
|
final SettingProvider.Provider<?> provider = providerImpl.getConstructor().newInstance();
|
||||||
integrationSettings.put( valueProvider.getKey(), valueProvider.getValue() );
|
integrationSettings.put( providerAnn.settingName(), provider.getSetting() );
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
log.error( "Error obtaining special value for " + _class.getName(), e );
|
log.error( "Error obtaining setting provider for " + providerImpl.getName(), e );
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,6 @@ import org.hibernate.resource.jdbc.spi.StatementInspector;
|
||||||
|
|
||||||
import org.hibernate.testing.orm.domain.DomainModelDescriptor;
|
import org.hibernate.testing.orm.domain.DomainModelDescriptor;
|
||||||
import org.hibernate.testing.orm.domain.StandardDomainModel;
|
import org.hibernate.testing.orm.domain.StandardDomainModel;
|
||||||
import org.hibernate.testing.orm.jpa.NonStringValueSettingProvider;
|
|
||||||
import org.junit.jupiter.api.TestInstance;
|
import org.junit.jupiter.api.TestInstance;
|
||||||
import org.junit.jupiter.api.extension.ExtendWith;
|
import org.junit.jupiter.api.extension.ExtendWith;
|
||||||
|
|
||||||
|
@ -48,8 +47,6 @@ public @interface Jpa {
|
||||||
*/
|
*/
|
||||||
Setting[] integrationSettings() default {};
|
Setting[] integrationSettings() default {};
|
||||||
|
|
||||||
Class<? extends NonStringValueSettingProvider>[] nonStringValueSettingProviders() default {};
|
|
||||||
|
|
||||||
// todo : multiple persistence units?
|
// todo : multiple persistence units?
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -57,6 +54,8 @@ public @interface Jpa {
|
||||||
*/
|
*/
|
||||||
Setting[] properties() default {};
|
Setting[] properties() default {};
|
||||||
|
|
||||||
|
SettingProvider[] settingProviders() default {};
|
||||||
|
|
||||||
boolean generateStatistics() default false;
|
boolean generateStatistics() default false;
|
||||||
boolean exportSchema() default true;
|
boolean exportSchema() default true;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue