Only set mapping resources when present
This commit sets a mapping resources list only when there is at least an element in it. This allows the default fallback of finding an "orm.xml" file to kick in when no customization has been applied. Closes gh-11964
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
* Copyright 2012-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -54,6 +54,7 @@ import org.springframework.orm.jpa.support.OpenEntityManagerInViewInterceptor;
|
||||
import org.springframework.orm.jpa.vendor.AbstractJpaVendorAdapter;
|
||||
import org.springframework.transaction.PlatformTransactionManager;
|
||||
import org.springframework.transaction.jta.JtaTransactionManager;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
@@ -164,7 +165,9 @@ public abstract class JpaBaseConfiguration implements BeanFactoryAware {
|
||||
|
||||
private String[] getMappingResources() {
|
||||
List<String> mappingResources = this.properties.getMappingResources();
|
||||
return mappingResources.toArray(new String[mappingResources.size()]);
|
||||
return (!ObjectUtils.isEmpty(mappingResources)
|
||||
? mappingResources.toArray(new String[mappingResources.size()])
|
||||
: null);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
* Copyright 2012-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -29,6 +29,7 @@ import org.springframework.orm.jpa.JpaVendorAdapter;
|
||||
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
|
||||
import org.springframework.orm.jpa.persistenceunit.PersistenceUnitManager;
|
||||
import org.springframework.util.ClassUtils;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
/**
|
||||
* Convenient builder for JPA EntityManagerFactory instances. Collects common
|
||||
@@ -220,7 +221,7 @@ public class EntityManagerFactoryBuilder {
|
||||
entityManagerFactoryBean.getJpaPropertyMap()
|
||||
.putAll(EntityManagerFactoryBuilder.this.jpaProperties);
|
||||
entityManagerFactoryBean.getJpaPropertyMap().putAll(this.properties);
|
||||
if (this.mappingResources != null) {
|
||||
if (!ObjectUtils.isEmpty(this.mappingResources)) {
|
||||
entityManagerFactoryBean.setMappingResources(this.mappingResources);
|
||||
}
|
||||
URL rootLocation = EntityManagerFactoryBuilder.this.persistenceUnitRootLocation;
|
||||
|
||||
Reference in New Issue
Block a user