Merge branch '6.0.x'

# Conflicts:
#	spring-orm/src/main/java/org/springframework/orm/hibernate5/SpringBeanContainer.java
This commit is contained in:
Juergen Hoeller 2023-06-17 11:41:07 +02:00
commit 5bf213948c
2 changed files with 16 additions and 7 deletions

View File

@ -172,7 +172,7 @@
<value>2601,2627</value>
</property>
<property name="dataIntegrityViolationCodes">
<value>544,8114,8115</value>
<value>544,2628,8114,8115</value>
</property>
<property name="dataAccessResourceFailureCodes">
<value>4060</value>

View File

@ -180,14 +180,23 @@ public final class SpringBeanContainer implements BeanContainer {
try {
if (lifecycleOptions.useJpaCompliantCreation()) {
Object bean = this.beanFactory.autowire(beanType, AutowireCapableBeanFactory.AUTOWIRE_CONSTRUCTOR, false);
this.beanFactory.autowireBeanProperties(bean, AutowireCapableBeanFactory.AUTOWIRE_NO, false);
this.beanFactory.applyBeanPropertyValues(bean, name);
bean = this.beanFactory.initializeBean(bean, name);
return new SpringContainedBean<>(bean, beanInstance -> this.beanFactory.destroyBean(name, beanInstance));
if (this.beanFactory.containsBean(name)) {
Object bean = this.beanFactory.autowire(beanType, AutowireCapableBeanFactory.AUTOWIRE_CONSTRUCTOR, false);
this.beanFactory.autowireBeanProperties(bean, AutowireCapableBeanFactory.AUTOWIRE_NO, false);
this.beanFactory.applyBeanPropertyValues(bean, name);
bean = this.beanFactory.initializeBean(bean, name);
return new SpringContainedBean<>(bean, beanInstance -> this.beanFactory.destroyBean(name, beanInstance));
}
else {
return new SpringContainedBean<>(
this.beanFactory.createBean(beanType),
this.beanFactory::destroyBean);
}
}
else {
return new SpringContainedBean<>(this.beanFactory.getBean(name, beanType));
return (this.beanFactory.containsBean(name) ?
new SpringContainedBean<>(this.beanFactory.getBean(name, beanType)) :
new SpringContainedBean<>(this.beanFactory.getBean(beanType)));
}
}
catch (BeansException ex) {