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