提交 103c648a 编写于 作者: J Juergen Hoeller 提交者: Chris Beams

added protected "isPersistenceUnitOverrideAllowed()" method to...

added protected "isPersistenceUnitOverrideAllowed()" method to DefaultPersistenceUnitManager (SPR-8925)
上级 e0252ad0
......@@ -353,7 +353,7 @@ public class DefaultPersistenceUnitManager
}
postProcessPersistenceUnitInfo(pui);
String name = pui.getPersistenceUnitName();
if (!this.persistenceUnitInfoNames.add(name)) {
if (!this.persistenceUnitInfoNames.add(name) && !isPersistenceUnitOverrideAllowed()) {
StringBuilder msg = new StringBuilder();
msg.append("Conflicting persistence unit definitions for name '").append(name).append("': ");
msg.append(pui.getPersistenceUnitRootUrl()).append(", ");
......@@ -478,7 +478,7 @@ public class DefaultPersistenceUnitManager
/**
* Hook method allowing subclasses to customize each PersistenceUnitInfo.
* <p>Default implementation delegates to all registered PersistenceUnitPostProcessors.
* <p>The default implementation delegates to all registered PersistenceUnitPostProcessors.
* It is usually preferable to register further entity classes, jar files etc there
* rather than in a subclass of this manager, to be able to reuse the post-processors.
* @param pui the chosen PersistenceUnitInfo, as read from <code>persistence.xml</code>.
......@@ -494,6 +494,15 @@ public class DefaultPersistenceUnitManager
}
}
/**
* Return whether an override of a same-named persistence unit is allowed.
* <p>Default is <code>false</code>. May be overridden to return <code>true</code>,
* for example if {@link #postProcessPersistenceUnitInfo} is able to handle that case.
*/
protected boolean isPersistenceUnitOverrideAllowed() {
return false;
}
public PersistenceUnitInfo obtainDefaultPersistenceUnitInfo() {
if (this.persistenceUnitInfoNames.isEmpty()) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册