提交 f32e4077 编写于 作者: J Juergen Hoeller 提交者: unknown

same-named unit from persistence.xml overrides in case of conflict with default unit

Issue: SPR-9741
上级 10a4e88e
......@@ -21,7 +21,6 @@ import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.net.URL;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
......@@ -375,10 +374,18 @@ public class DefaultPersistenceUnitManager
* as defined in the JPA specification.
*/
private List<SpringPersistenceUnitInfo> readPersistenceUnitInfos() {
PersistenceUnitReader reader = new PersistenceUnitReader(this.resourcePatternResolver, this.dataSourceLookup);
List<SpringPersistenceUnitInfo> infos = new LinkedList<SpringPersistenceUnitInfo>();
infos.addAll(Arrays.asList(reader.readPersistenceUnitInfos(this.persistenceXmlLocations)));
if (this.packagesToScan != null || this.mappingResources != null) {
boolean buildDefaultUnit = (this.packagesToScan != null || this.mappingResources != null);
PersistenceUnitReader reader = new PersistenceUnitReader(this.resourcePatternResolver, this.dataSourceLookup);
SpringPersistenceUnitInfo[] readInfos = reader.readPersistenceUnitInfos(this.persistenceXmlLocations);
for (SpringPersistenceUnitInfo readInfo : readInfos) {
infos.add(readInfo);
if (this.defaultPersistenceUnitName != null &&
this.defaultPersistenceUnitName.equals(readInfo.getPersistenceUnitName())) {
buildDefaultUnit = false;
}
}
if (buildDefaultUnit) {
infos.add(buildDefaultPersistenceUnitInfo());
}
return infos;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册