Merge branch '6.0.x'
This commit is contained in:
@@ -54,7 +54,7 @@ import org.springframework.util.ClassUtils;
|
|||||||
*/
|
*/
|
||||||
class BeanValidationBeanRegistrationAotProcessor implements BeanRegistrationAotProcessor {
|
class BeanValidationBeanRegistrationAotProcessor implements BeanRegistrationAotProcessor {
|
||||||
|
|
||||||
private static final boolean isBeanValidationPresent = ClassUtils.isPresent(
|
private static final boolean beanValidationPresent = ClassUtils.isPresent(
|
||||||
"jakarta.validation.Validation", BeanValidationBeanRegistrationAotProcessor.class.getClassLoader());
|
"jakarta.validation.Validation", BeanValidationBeanRegistrationAotProcessor.class.getClassLoader());
|
||||||
|
|
||||||
private static final Log logger = LogFactory.getLog(BeanValidationBeanRegistrationAotProcessor.class);
|
private static final Log logger = LogFactory.getLog(BeanValidationBeanRegistrationAotProcessor.class);
|
||||||
@@ -63,13 +63,16 @@ class BeanValidationBeanRegistrationAotProcessor implements BeanRegistrationAotP
|
|||||||
@Override
|
@Override
|
||||||
@Nullable
|
@Nullable
|
||||||
public BeanRegistrationAotContribution processAheadOfTime(RegisteredBean registeredBean) {
|
public BeanRegistrationAotContribution processAheadOfTime(RegisteredBean registeredBean) {
|
||||||
if (isBeanValidationPresent) {
|
if (beanValidationPresent) {
|
||||||
return BeanValidationDelegate.processAheadOfTime(registeredBean);
|
return BeanValidationDelegate.processAheadOfTime(registeredBean);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Inner class to avoid a hard dependency on the Bean Validation API at runtime.
|
||||||
|
*/
|
||||||
private static class BeanValidationDelegate {
|
private static class BeanValidationDelegate {
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2002-2022 the original author or authors.
|
* Copyright 2002-2023 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -444,9 +444,12 @@ public class DefaultPersistenceUnitManager
|
|||||||
|
|
||||||
List<SpringPersistenceUnitInfo> puis = readPersistenceUnitInfos();
|
List<SpringPersistenceUnitInfo> puis = readPersistenceUnitInfos();
|
||||||
for (SpringPersistenceUnitInfo pui : puis) {
|
for (SpringPersistenceUnitInfo pui : puis) {
|
||||||
|
// Determine default persistence unit root URL
|
||||||
if (pui.getPersistenceUnitRootUrl() == null) {
|
if (pui.getPersistenceUnitRootUrl() == null) {
|
||||||
pui.setPersistenceUnitRootUrl(determineDefaultPersistenceUnitRootUrl());
|
pui.setPersistenceUnitRootUrl(determineDefaultPersistenceUnitRootUrl());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Override DataSource and cache/validation mode
|
||||||
if (pui.getJtaDataSource() == null && this.defaultJtaDataSource != null) {
|
if (pui.getJtaDataSource() == null && this.defaultJtaDataSource != null) {
|
||||||
pui.setJtaDataSource(this.defaultJtaDataSource);
|
pui.setJtaDataSource(this.defaultJtaDataSource);
|
||||||
}
|
}
|
||||||
@@ -459,13 +462,17 @@ public class DefaultPersistenceUnitManager
|
|||||||
if (this.validationMode != null) {
|
if (this.validationMode != null) {
|
||||||
pui.setValidationMode(this.validationMode);
|
pui.setValidationMode(this.validationMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Initialize persistence unit ClassLoader
|
||||||
if (this.loadTimeWeaver != null) {
|
if (this.loadTimeWeaver != null) {
|
||||||
pui.init(this.loadTimeWeaver);
|
pui.init(this.loadTimeWeaver);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
pui.init(this.resourcePatternResolver.getClassLoader());
|
pui.init(this.resourcePatternResolver.getClassLoader());
|
||||||
}
|
}
|
||||||
|
|
||||||
postProcessPersistenceUnitInfo(pui);
|
postProcessPersistenceUnitInfo(pui);
|
||||||
|
|
||||||
String name = pui.getPersistenceUnitName();
|
String name = pui.getPersistenceUnitName();
|
||||||
if (!this.persistenceUnitInfoNames.add(name) && !isPersistenceUnitOverrideAllowed()) {
|
if (!this.persistenceUnitInfoNames.add(name) && !isPersistenceUnitOverrideAllowed()) {
|
||||||
StringBuilder msg = new StringBuilder();
|
StringBuilder msg = new StringBuilder();
|
||||||
|
|||||||
@@ -163,6 +163,9 @@ public class HibernateJpaVendorAdapter extends AbstractJpaVendorAdapter {
|
|||||||
PhysicalConnectionHandlingMode.DELAYED_ACQUISITION_AND_HOLD);
|
PhysicalConnectionHandlingMode.DELAYED_ACQUISITION_AND_HOLD);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// For SpringBeanContainer to be called on Hibernate 6.2
|
||||||
|
jpaProperties.put("hibernate.cdi.extensions", "true");
|
||||||
|
|
||||||
return jpaProperties;
|
return jpaProperties;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user