HHH-15563 BeanValidation integration should prioritize jakarta.persistence.validation over javax.persistence.validation
This commit is contained in:
parent
04302caba0
commit
ba9bd35c9d
|
@ -21,6 +21,6 @@ hibernate.max_fetch_depth 5
|
|||
hibernate.cache.region_prefix hibernate.test
|
||||
hibernate.cache.region.factory_class org.hibernate.testing.cache.CachingRegionFactory
|
||||
|
||||
javax.persistence.validation.mode=NONE
|
||||
jakarta.persistence.validation.mode=NONE
|
||||
hibernate.service.allow_crawling=false
|
||||
hibernate.session.events.log=true
|
|
@ -21,6 +21,6 @@ hibernate.max_fetch_depth 5
|
|||
hibernate.cache.region_prefix hibernate.test
|
||||
hibernate.cache.region.factory_class org.hibernate.testing.cache.CachingRegionFactory
|
||||
|
||||
javax.persistence.validation.mode=NONE
|
||||
jakarta.persistence.validation.mode=NONE
|
||||
hibernate.service.allow_crawling=false
|
||||
hibernate.session.events.log=true
|
|
@ -21,6 +21,6 @@ hibernate.max_fetch_depth 5
|
|||
hibernate.cache.region_prefix hibernate.test
|
||||
hibernate.cache.region.factory_class org.hibernate.testing.cache.CachingRegionFactory
|
||||
|
||||
javax.persistence.validation.mode=NONE
|
||||
jakarta.persistence.validation.mode=NONE
|
||||
hibernate.service.allow_crawling=false
|
||||
hibernate.session.events.log=true
|
|
@ -21,6 +21,6 @@ hibernate.max_fetch_depth 5
|
|||
hibernate.cache.region_prefix hibernate.test
|
||||
hibernate.cache.region.factory_class org.hibernate.testing.cache.CachingRegionFactory
|
||||
|
||||
javax.persistence.validation.mode=NONE
|
||||
jakarta.persistence.validation.mode=NONE
|
||||
hibernate.service.allow_crawling=false
|
||||
hibernate.session.events.log=true
|
|
@ -21,6 +21,6 @@ hibernate.max_fetch_depth 5
|
|||
hibernate.cache.region_prefix hibernate.test
|
||||
hibernate.cache.region.factory_class org.hibernate.testing.cache.CachingRegionFactory
|
||||
|
||||
javax.persistence.validation.mode=NONE
|
||||
jakarta.persistence.validation.mode=NONE
|
||||
hibernate.service.allow_crawling=false
|
||||
hibernate.session.events.log=true
|
|
@ -90,9 +90,9 @@ public class BeanValidationIntegrator implements Integrator {
|
|||
ServiceRegistryImplementor serviceRegistry = sessionFactory.getServiceRegistry();
|
||||
final ConfigurationService cfgService = serviceRegistry.getService( ConfigurationService.class );
|
||||
// IMPL NOTE : see the comments on ActivationContext.getValidationModes() as to why this is multi-valued...
|
||||
Object modeSetting = cfgService.getSettings().get( MODE_PROPERTY );
|
||||
Object modeSetting = cfgService.getSettings().get( JAKARTA_MODE_PROPERTY );
|
||||
if ( modeSetting == null ) {
|
||||
modeSetting = cfgService.getSettings().get( JAKARTA_MODE_PROPERTY );
|
||||
modeSetting = cfgService.getSettings().get( MODE_PROPERTY );
|
||||
}
|
||||
final Set<ValidationMode> modes = ValidationMode.getModes( modeSetting );
|
||||
if ( modes.size() > 1 ) {
|
||||
|
@ -159,11 +159,11 @@ public class BeanValidationIntegrator implements Integrator {
|
|||
|
||||
private boolean isBeanValidationApiAvailable(ClassLoaderService classLoaderService) {
|
||||
try {
|
||||
classLoaderService.classForName( BV_CHECK_CLASS );
|
||||
classLoaderService.classForName( JAKARTA_BV_CHECK_CLASS );
|
||||
}
|
||||
catch (Exception e) {
|
||||
try {
|
||||
classLoaderService.classForName( JAKARTA_BV_CHECK_CLASS );
|
||||
classLoaderService.classForName( BV_CHECK_CLASS );
|
||||
}
|
||||
catch (Exception e2) {
|
||||
return false;
|
||||
|
|
|
@ -56,9 +56,9 @@ public class GroupsPerOperation {
|
|||
}
|
||||
|
||||
public static Class<?>[] buildGroupsForOperation(Operation operation, Map settings, ClassLoaderAccess classLoaderAccess) {
|
||||
Object property = settings.get( operation.getGroupPropertyName() );
|
||||
Object property = settings.get( operation.getJakartaGroupPropertyName() );
|
||||
if ( property == null ) {
|
||||
property = settings.get( operation.getJakartaGroupPropertyName() );
|
||||
property = settings.get( operation.getGroupPropertyName() );
|
||||
}
|
||||
|
||||
if ( property == null ) {
|
||||
|
@ -92,7 +92,7 @@ public class GroupsPerOperation {
|
|||
}
|
||||
|
||||
//null is bad and excluded by instanceof => exception is raised
|
||||
throw new HibernateException( JPA_GROUP_PREFIX + operation.getGroupPropertyName() + " is of unknown type: String or Class<?>[] only");
|
||||
throw new HibernateException( JAKARTA_JPA_GROUP_PREFIX + operation.getGroupPropertyName() + " is of unknown type: String or Class<?>[] only");
|
||||
}
|
||||
|
||||
public Class<?>[] get(Operation operation) {
|
||||
|
|
|
@ -54,7 +54,7 @@ public enum ValidationMode {
|
|||
return valueOf( modeProperty.trim().toUpperCase(Locale.ROOT) );
|
||||
}
|
||||
catch ( IllegalArgumentException e ) {
|
||||
throw new HibernateException( "Unknown validation mode in " + BeanValidationIntegrator.MODE_PROPERTY + ": " + modeProperty );
|
||||
throw new HibernateException( "Unknown validation mode in " + BeanValidationIntegrator.JAKARTA_MODE_PROPERTY + ": " + modeProperty );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1544,7 +1544,7 @@ public interface CoreMessageLogger extends BasicLogger {
|
|||
void explicitSkipLockedLockCombo();
|
||||
|
||||
@LogMessage(level = INFO)
|
||||
@Message(value = "'javax.persistence.validation.mode' named multiple values : %s", id = 448)
|
||||
@Message(value = "'jakarta.persistence.validation.mode' named multiple values : %s", id = 448)
|
||||
void multipleValidationModes(String modes);
|
||||
|
||||
@LogMessage(level = WARN)
|
||||
|
|
|
@ -45,7 +45,7 @@ public class BeanValidationAutoTest extends BaseCoreFunctionalTestCase {
|
|||
@Override
|
||||
protected void configure(Configuration cfg) {
|
||||
super.configure( cfg );
|
||||
cfg.setProperty( "javax.persistence.validation.mode", "AUTO" );
|
||||
cfg.setProperty( "jakarta.persistence.validation.mode", "AUTO" );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -51,7 +51,7 @@ public class BeanValidationDisabledTest extends BaseNonConfigCoreFunctionalTestC
|
|||
|
||||
@Override
|
||||
protected void addSettings(Map<String,Object> settings) {
|
||||
settings.put( "javax.persistence.validation.mode", "none" );
|
||||
settings.put( "jakarta.persistence.validation.mode", "none" );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -84,7 +84,7 @@ public class BeanValidationGroupsTest extends BaseCoreFunctionalTestCase {
|
|||
Default.class.getName() + ", " + Strict.class.getName()
|
||||
);
|
||||
cfg.setProperty( "hibernate.validator.apply_to_ddl", "false" );
|
||||
cfg.setProperty( "javax.persistence.validation.mode", "auto" );
|
||||
cfg.setProperty( "jakarta.persistence.validation.mode", "auto" );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -70,6 +70,6 @@ public class BeanValidationProvidedFactoryTest extends BaseCoreFunctionalTestCas
|
|||
configuration.messageInterpolator( messageInterpolator );
|
||||
ValidatorFactory vf = configuration.buildValidatorFactory();
|
||||
cfg.getProperties().put( "jakarta.persistence.validation.factory", vf );
|
||||
cfg.setProperty( "javax.persistence.validation.mode", "AUTO" );
|
||||
cfg.setProperty( "jakarta.persistence.validation.mode", "AUTO" );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -84,7 +84,7 @@ public class DDLTest extends BaseNonConfigCoreFunctionalTestCase {
|
|||
|
||||
@Override
|
||||
protected void addSettings(Map<String,Object> settings) {
|
||||
settings.put( "javax.persistence.validation.mode", "ddl" );
|
||||
settings.put( "jakarta.persistence.validation.mode", "ddl" );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -34,7 +34,7 @@ public class DDLWithoutCallbackTest extends BaseNonConfigCoreFunctionalTestCase
|
|||
|
||||
@Override
|
||||
protected void addSettings(Map<String,Object> settings) {
|
||||
settings.put( "javax.persistence.validation.mode", "ddl" );
|
||||
settings.put( "jakarta.persistence.validation.mode", "ddl" );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -193,7 +193,7 @@ public class HibernateTraversableResolverTest extends BaseCoreFunctionalTestCase
|
|||
@Override
|
||||
protected void configure(Configuration cfg) {
|
||||
super.configure( cfg );
|
||||
cfg.setProperty( "javax.persistence.validation.mode", "AUTO" );
|
||||
cfg.setProperty( "jakarta.persistence.validation.mode", "AUTO" );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -39,7 +39,7 @@ public class MergeNotNullCollectionTest extends BaseCoreFunctionalTestCase {
|
|||
@Override
|
||||
protected void configure(Configuration cfg) {
|
||||
super.configure( cfg );
|
||||
cfg.setProperty( "javax.persistence.validation.mode", "AUTO" );
|
||||
cfg.setProperty( "jakarta.persistence.validation.mode", "AUTO" );
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -48,7 +48,7 @@ public class MergeNotNullCollectionUsingIdentityTest extends BaseCoreFunctionalT
|
|||
@Override
|
||||
protected void configure(Configuration cfg) {
|
||||
super.configure( cfg );
|
||||
cfg.setProperty( "javax.persistence.validation.mode", "AUTO" );
|
||||
cfg.setProperty( "jakarta.persistence.validation.mode", "AUTO" );
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -24,7 +24,7 @@ public class NotNullManyToOneTest extends BaseCoreFunctionalTestCase {
|
|||
|
||||
@Override
|
||||
protected void configure(Configuration configuration) {
|
||||
configuration.setProperty( AvailableSettings.JPA_VALIDATION_MODE, ValidationMode.AUTO.name() );
|
||||
configuration.setProperty( AvailableSettings.JAKARTA_VALIDATION_MODE, ValidationMode.AUTO.name() );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -28,7 +28,7 @@ import static org.junit.jupiter.api.Assertions.fail;
|
|||
*/
|
||||
@Jpa(
|
||||
annotatedClasses = { CupHolder.class },
|
||||
integrationSettings = { @Setting(name = AvailableSettings.JPA_VALIDATION_MODE, value = "auto") }
|
||||
integrationSettings = { @Setting(name = AvailableSettings.JAKARTA_VALIDATION_MODE, value = "auto") }
|
||||
)
|
||||
public class BeanValidationTest {
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ import org.junit.jupiter.api.Test;
|
|||
annotatedClasses = {
|
||||
RemoveOrderingTest.Person.class, RemoveOrderingTest.Company.class
|
||||
},
|
||||
integrationSettings = { @Setting(name = AvailableSettings.JPA_VALIDATION_MODE, value = "NONE") }
|
||||
integrationSettings = { @Setting(name = AvailableSettings.JAKARTA_VALIDATION_MODE, value = "NONE") }
|
||||
)
|
||||
public class RemoveOrderingTest {
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ public class NonReflectiveBinderTest {
|
|||
@BeforeEach
|
||||
public void setUp() throws Exception {
|
||||
ssr = new StandardServiceRegistryBuilder()
|
||||
.applySetting( "javax.persistence.validation.mode", "none" )
|
||||
.applySetting( "jakarta.persistence.validation.mode", "none" )
|
||||
.build();
|
||||
metadata = new MetadataSources( ssr )
|
||||
.addResource( "org/hibernate/orm/test/legacy/Wicked.hbm.xml" )
|
||||
|
|
|
@ -22,7 +22,7 @@ hibernate.max_fetch_depth 5
|
|||
hibernate.cache.region_prefix hibernate.test
|
||||
hibernate.cache.region.factory_class org.hibernate.testing.cache.CachingRegionFactory
|
||||
|
||||
javax.persistence.validation.mode=NONE
|
||||
jakarta.persistence.validation.mode=NONE
|
||||
hibernate.service.allow_crawling=false
|
||||
hibernate.session.events.log=true
|
||||
hibernate.hql.bulk_id_strategy.global_temporary.drop_tables=true
|
||||
|
|
|
@ -22,7 +22,7 @@ hibernate.max_fetch_depth 5
|
|||
hibernate.cache.region_prefix hibernate.test
|
||||
hibernate.cache.region.factory_class org.hibernate.testing.cache.CachingRegionFactory
|
||||
|
||||
javax.persistence.validation.mode=NONE
|
||||
jakarta.persistence.validation.mode=NONE
|
||||
hibernate.service.allow_crawling=false
|
||||
hibernate.session.events.log=true
|
||||
hibernate.hql.bulk_id_strategy.global_temporary.drop_tables=true
|
|
@ -22,7 +22,7 @@ hibernate.max_fetch_depth 5
|
|||
hibernate.cache.region_prefix hibernate.test
|
||||
hibernate.cache.region.factory_class org.hibernate.testing.cache.CachingRegionFactory
|
||||
|
||||
javax.persistence.validation.mode=NONE
|
||||
jakarta.persistence.validation.mode=NONE
|
||||
hibernate.service.allow_crawling=false
|
||||
hibernate.session.events.log=true
|
||||
hibernate.hql.bulk_id_strategy.global_temporary.drop_tables=true
|
||||
|
|
Loading…
Reference in New Issue