Browse Source

compatibility with OpenJPA 2.0 (support for persistence.xml versioning; SPR-6975)

git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@3104 50f2f4bb-b051-0410-bef5-90022cba6387
pull/1/head
Juergen Hoeller 16 years ago
parent
commit
2c71b5b5ff
  1. 10
      org.springframework.orm/src/main/java/org/springframework/orm/jpa/persistenceunit/PersistenceUnitReader.java

10
org.springframework.orm/src/main/java/org/springframework/orm/jpa/persistenceunit/PersistenceUnitReader.java

@ -51,6 +51,8 @@ import org.springframework.util.xml.SimpleSaxErrorHandler; @@ -51,6 +51,8 @@ import org.springframework.util.xml.SimpleSaxErrorHandler;
*/
class PersistenceUnitReader {
private static final String PERSISTENCE_VERSION = "version";
private static final String PERSISTENCE_UNIT = "persistence-unit";
private static final String UNIT_NAME = "name";
@ -170,10 +172,11 @@ class PersistenceUnitReader { @@ -170,10 +172,11 @@ class PersistenceUnitReader {
Resource resource, Document document, List<SpringPersistenceUnitInfo> infos) throws IOException {
Element persistence = document.getDocumentElement();
String version = persistence.getAttribute(PERSISTENCE_VERSION);
URL unitRootURL = determinePersistenceUnitRootUrl(resource);
List<Element> units = DomUtils.getChildElementsByTagName(persistence, PERSISTENCE_UNIT);
for (Element unit : units) {
SpringPersistenceUnitInfo info = parsePersistenceUnitInfo(unit);
SpringPersistenceUnitInfo info = parsePersistenceUnitInfo(unit, version);
info.setPersistenceUnitRootUrl(unitRootURL);
infos.add(info);
}
@ -224,9 +227,12 @@ class PersistenceUnitReader { @@ -224,9 +227,12 @@ class PersistenceUnitReader {
/**
* Parse the unit info DOM element.
*/
protected SpringPersistenceUnitInfo parsePersistenceUnitInfo(Element persistenceUnit) throws IOException {
protected SpringPersistenceUnitInfo parsePersistenceUnitInfo(Element persistenceUnit, String version) throws IOException { // JC: Changed
SpringPersistenceUnitInfo unitInfo = new SpringPersistenceUnitInfo();
// set JPA version (1.0 or 2.0)
unitInfo.setPersistenceXMLSchemaVersion(version);
// set unit name
unitInfo.setPersistenceUnitName(persistenceUnit.getAttribute(UNIT_NAME).trim());

Loading…
Cancel
Save