Fixed misunderstanding with respect to excludeUnlistedClasses default in JPA 2.0

Issue: SPR-10767
This commit is contained in:
Juergen Hoeller
2013-07-31 23:40:59 +02:00
parent ae0f23e942
commit d0948f1f03
3 changed files with 37 additions and 44 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2013 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.
@@ -21,7 +21,6 @@ import java.io.InputStream;
import java.net.URL;
import java.util.LinkedList;
import java.util.List;
import javax.persistence.spi.PersistenceUnitTransactionType;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
@@ -29,6 +28,11 @@ import javax.xml.parsers.ParserConfigurationException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.xml.sax.ErrorHandler;
import org.xml.sax.SAXException;
import org.springframework.core.io.Resource;
import org.springframework.core.io.support.ResourcePatternResolver;
import org.springframework.jdbc.datasource.lookup.DataSourceLookup;
@@ -37,10 +41,6 @@ import org.springframework.util.ResourceUtils;
import org.springframework.util.StringUtils;
import org.springframework.util.xml.DomUtils;
import org.springframework.util.xml.SimpleSaxErrorHandler;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.xml.sax.ErrorHandler;
import org.xml.sax.SAXException;
/**
* Internal helper class for reading JPA-compliant {@code persistence.xml} files.
@@ -81,8 +81,6 @@ class PersistenceUnitReader {
private static final String META_INF = "META-INF";
private static final String VERSION_1 = "1.0";
private final Log logger = LogFactory.getLog(getClass());
@@ -249,7 +247,7 @@ class PersistenceUnitReader {
unitInfo.setTransactionType(PersistenceUnitTransactionType.valueOf(txType));
}
// data-source
// evaluate data sources
String jtaDataSource = DomUtils.getChildElementValueByTagName(persistenceUnit, JTA_DATA_SOURCE);
if (StringUtils.hasText(jtaDataSource)) {
unitInfo.setJtaDataSource(this.dataSourceLookup.getDataSource(jtaDataSource.trim()));
@@ -268,14 +266,9 @@ class PersistenceUnitReader {
// exclude unlisted classes
Element excludeUnlistedClasses = DomUtils.getChildElementByTagName(persistenceUnit, EXCLUDE_UNLISTED_CLASSES);
if (excludeUnlistedClasses == null) {
// element is not defined, use default appropriate for version
unitInfo.setExcludeUnlistedClasses(!VERSION_1.equals(version));
}
else {
if (excludeUnlistedClasses != null) {
String excludeText = DomUtils.getTextValue(excludeUnlistedClasses);
unitInfo.setExcludeUnlistedClasses(StringUtils.isEmpty(excludeText) ||
Boolean.valueOf(excludeText));
unitInfo.setExcludeUnlistedClasses(!StringUtils.hasText(excludeText) || Boolean.valueOf(excludeText));
}
// set JPA 2.0 shared cache mode