mirror of https://github.com/apache/openjpa.git
OPENJPA-2010: Temporarily reverting to unroll other changes."
git-svn-id: https://svn.apache.org/repos/asf/openjpa/branches/2.1.x@1141143 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
bebc03a951
commit
95722e35c8
|
@ -529,12 +529,11 @@ public class MappingTool
|
||||||
if (_mappingWriter != null) {
|
if (_mappingWriter != null) {
|
||||||
output = new HashMap<File, String>();
|
output = new HashMap<File, String>();
|
||||||
File tmp = new File("openjpatmp");
|
File tmp = new File("openjpatmp");
|
||||||
for (int i = 0; i < mappings.length; i++) {
|
for (int i = 0; i < mappings.length; i++)
|
||||||
mappings[i].setSource(tmp, SourceTracker.SRC_OTHER, "openjpatmp");
|
mappings[i].setSource(tmp, SourceTracker.SRC_OTHER);
|
||||||
}
|
for (int i = 0; i < queries.length; i++)
|
||||||
for (int i = 0; i < queries.length; i++) {
|
queries[i].setSource(tmp, queries[i].getSourceScope(),
|
||||||
queries[i].setSource(tmp, queries[i].getSourceScope(), SourceTracker.SRC_OTHER, "openjpatmp");
|
SourceTracker.SRC_OTHER);
|
||||||
}
|
|
||||||
for (int i = 0; i < seqs.length; i++)
|
for (int i = 0; i < seqs.length; i++)
|
||||||
seqs[i].setSource(tmp, seqs[i].getSourceScope(),
|
seqs[i].setSource(tmp, seqs[i].getSourceScope(),
|
||||||
SourceTracker.SRC_OTHER);
|
SourceTracker.SRC_OTHER);
|
||||||
|
@ -709,7 +708,7 @@ public class MappingTool
|
||||||
&& fmds[i].getDeclaredType() != Object.class)
|
&& fmds[i].getDeclaredType() != Object.class)
|
||||||
fmds[i].setDeclaredTypeCode(JavaTypes.PC);
|
fmds[i].setDeclaredTypeCode(JavaTypes.PC);
|
||||||
}
|
}
|
||||||
meta.setSource(_file, meta.getSourceType(), _file == null ? "": _file.getPath() );
|
meta.setSource(_file, meta.getSourceType());
|
||||||
meta.setResolve(MODE_META, true);
|
meta.setResolve(MODE_META, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -381,11 +381,10 @@ public abstract class AbstractCFMetaDataFactory
|
||||||
if (queries[i].getSourceMode() == MODE_QUERY
|
if (queries[i].getSourceMode() == MODE_QUERY
|
||||||
|| (mode & queries[i].getSourceMode()) == 0)
|
|| (mode & queries[i].getSourceMode()) == 0)
|
||||||
continue;
|
continue;
|
||||||
if (queries[i].getSourceFile() == null) {
|
if (queries[i].getSourceFile() == null)
|
||||||
File defaultFile = defaultSourceFile(queries[i], clsNames);
|
queries[i].setSource(defaultSourceFile(queries[i],
|
||||||
queries[i].setSource(defaultFile, queries[i].getSourceScope(), queries[i].getSourceType(),
|
clsNames), queries[i].getSourceScope(),
|
||||||
defaultFile == null ? "" : defaultFile.getPath());
|
queries[i].getSourceType());
|
||||||
}
|
|
||||||
if ((AccessController.doPrivileged(
|
if ((AccessController.doPrivileged(
|
||||||
J2DoPrivHelper.existsAction(queries[i].getSourceFile())))
|
J2DoPrivHelper.existsAction(queries[i].getSourceFile())))
|
||||||
.booleanValue()) {
|
.booleanValue()) {
|
||||||
|
@ -424,11 +423,9 @@ public abstract class AbstractCFMetaDataFactory
|
||||||
for (int i = 0; i < queries.length; i++) {
|
for (int i = 0; i < queries.length; i++) {
|
||||||
if (queries[i].getSourceMode() != MODE_QUERY)
|
if (queries[i].getSourceMode() != MODE_QUERY)
|
||||||
continue;
|
continue;
|
||||||
if (queries[i].getSourceFile() == null) {
|
if (queries[i].getSourceFile() == null)
|
||||||
File defaultFile = defaultSourceFile(queries[i], clsNames);
|
queries[i].setSource(defaultSourceFile(queries[i], clsNames),
|
||||||
queries[i].setSource(defaultFile, queries[i].getSourceScope(), queries[i].getSourceType(),
|
queries[i].getSourceScope(), queries[i].getSourceType());
|
||||||
defaultFile == null ? "" : defaultFile.getPath());
|
|
||||||
}
|
|
||||||
if ((AccessController.doPrivileged(
|
if ((AccessController.doPrivileged(
|
||||||
J2DoPrivHelper.existsAction(queries[i].getSourceFile())))
|
J2DoPrivHelper.existsAction(queries[i].getSourceFile())))
|
||||||
.booleanValue()) {
|
.booleanValue()) {
|
||||||
|
@ -525,8 +522,7 @@ public abstract class AbstractCFMetaDataFactory
|
||||||
* Set the current source file of the given metadata.
|
* Set the current source file of the given metadata.
|
||||||
*/
|
*/
|
||||||
protected void setSourceFile(ClassMetaData meta, File sourceFile) {
|
protected void setSourceFile(ClassMetaData meta, File sourceFile) {
|
||||||
meta.setSource(sourceFile, meta.getSourceType(), sourceFile != null ?
|
meta.setSource(sourceFile, meta.getSourceType());
|
||||||
sourceFile.getPath() : "");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -145,7 +145,6 @@ public class ClassMetaData
|
||||||
private final ValueMetaData _owner;
|
private final ValueMetaData _owner;
|
||||||
private final LifecycleMetaData _lifeMeta = new LifecycleMetaData(this);
|
private final LifecycleMetaData _lifeMeta = new LifecycleMetaData(this);
|
||||||
private File _srcFile = null;
|
private File _srcFile = null;
|
||||||
private String _srcName = null;
|
|
||||||
private int _srcType = SRC_OTHER;
|
private int _srcType = SRC_OTHER;
|
||||||
private int _lineNum = 0;
|
private int _lineNum = 0;
|
||||||
private int _colNum = 0;
|
private int _colNum = 0;
|
||||||
|
@ -2404,10 +2403,9 @@ public class ClassMetaData
|
||||||
return _srcType;
|
return _srcType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSource(File file, int srcType, String srcName) {
|
public void setSource(File file, int srcType) {
|
||||||
_srcFile = file;
|
_srcFile = file;
|
||||||
_srcType = srcType;
|
_srcType = srcType;
|
||||||
_srcName = srcName;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getResourceName() {
|
public String getResourceName() {
|
||||||
|
@ -2759,9 +2757,5 @@ public class ClassMetaData
|
||||||
return _cacheEnabled;
|
return _cacheEnabled;
|
||||||
return getPCSuperclassMetaData() != null ? getPCSuperclassMetaData().getCacheEnabled() : null;
|
return getPCSuperclassMetaData() != null ? getPCSuperclassMetaData().getCacheEnabled() : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getSourceName(){
|
|
||||||
return _srcName;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -175,7 +175,7 @@ public class MetaDataTool
|
||||||
&& fmds[i].getDeclaredType() != Object.class)
|
&& fmds[i].getDeclaredType() != Object.class)
|
||||||
fmds[i].setDeclaredTypeCode(JavaTypes.PC);
|
fmds[i].setDeclaredTypeCode(JavaTypes.PC);
|
||||||
}
|
}
|
||||||
meta.setSource(_file, meta.getSourceType(), _file == null ? "" : _file.getPath());
|
meta.setSource(_file, meta.getSourceType());
|
||||||
_flush = true;
|
_flush = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -205,7 +205,7 @@ public class MetaDataTool
|
||||||
output = new HashMap();
|
output = new HashMap();
|
||||||
File tmp = new File("openjpatmp");
|
File tmp = new File("openjpatmp");
|
||||||
for (int i = 0; i < metas.length; i++)
|
for (int i = 0; i < metas.length; i++)
|
||||||
metas[i].setSource(tmp, metas[i].getSourceType(), tmp.getPath());
|
metas[i].setSource(tmp, metas[i].getSourceType());
|
||||||
}
|
}
|
||||||
if (!mdf.store(metas, new QueryMetaData[0],
|
if (!mdf.store(metas, new QueryMetaData[0],
|
||||||
new SequenceMetaData[0], MODE_META, output))
|
new SequenceMetaData[0], MODE_META, output))
|
||||||
|
|
|
@ -60,7 +60,6 @@ public class QueryMetaData
|
||||||
private String _resultSetMappingName;
|
private String _resultSetMappingName;
|
||||||
private int _lineNum;
|
private int _lineNum;
|
||||||
private int _colNum;
|
private int _colNum;
|
||||||
private String _srcName;
|
|
||||||
private boolean _convertPositionalParametersToNamed;
|
private boolean _convertPositionalParametersToNamed;
|
||||||
/**
|
/**
|
||||||
* Construct with the given name.
|
* Construct with the given name.
|
||||||
|
@ -275,11 +274,10 @@ public class QueryMetaData
|
||||||
return _srcType;
|
return _srcType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSource(File file, Object scope, int srcType, String srcName) {
|
public void setSource(File file, Object scope, int srcType) {
|
||||||
_file = file;
|
_file = file;
|
||||||
_scope = scope;
|
_scope = scope;
|
||||||
_srcType = srcType;
|
_srcType = srcType;
|
||||||
_srcName = srcName;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getResourceName() {
|
public String getResourceName() {
|
||||||
|
@ -301,8 +299,4 @@ public class QueryMetaData
|
||||||
public void setColNumber(int colNum) {
|
public void setColNumber(int colNum) {
|
||||||
_colNum = colNum;
|
_colNum = colNum;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getSourceName() {
|
|
||||||
return _srcName;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -733,18 +733,12 @@ public class AnnotationPersistenceMetaDataParser
|
||||||
*/
|
*/
|
||||||
private ClassMetaData getMetaData() {
|
private ClassMetaData getMetaData() {
|
||||||
ClassMetaData meta = getRepository().getCachedMetaData(_cls);
|
ClassMetaData meta = getRepository().getCachedMetaData(_cls);
|
||||||
if (meta != null
|
if (meta != null &&
|
||||||
&& ((isMetaDataMode()
|
((isMetaDataMode() && (meta.getSourceMode() & MODE_META) != 0) ||
|
||||||
&& (meta.getSourceMode() & MODE_META) != 0)
|
(isMappingMode() &&
|
||||||
|| (isMappingMode() && (meta.getSourceMode() & MODE_MAPPING) != 0) ) ) {
|
(meta.getSourceMode() & MODE_MAPPING) != 0))) {
|
||||||
if (_log.isWarnEnabled()) {
|
if (_log.isWarnEnabled())
|
||||||
_log.warn(_loc.get("dup-metadata", _cls.getName()));
|
_log.warn(_loc.get("dup-metadata", _cls.getName()));
|
||||||
}
|
|
||||||
if(_log.isTraceEnabled()) {
|
|
||||||
_log.trace(String.format(
|
|
||||||
"MetaData originally obtained from file: %s under mode :%d with scope %s, and type :%d",
|
|
||||||
meta.getSourceName(), meta.getSourceMode(), meta.getSourceScope(), meta.getSourceType()));
|
|
||||||
}
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -752,8 +746,7 @@ public class AnnotationPersistenceMetaDataParser
|
||||||
meta = getRepository().addMetaData(_cls, getAccessCode(_cls));
|
meta = getRepository().addMetaData(_cls, getAccessCode(_cls));
|
||||||
meta.setEnvClassLoader(_envLoader);
|
meta.setEnvClassLoader(_envLoader);
|
||||||
meta.setSourceMode(MODE_NONE);
|
meta.setSourceMode(MODE_NONE);
|
||||||
meta.setSource(getSourceFile(), SourceTracker.SRC_ANNOTATIONS, getSourceFile() == null ? ""
|
meta.setSource(getSourceFile(), SourceTracker.SRC_ANNOTATIONS);
|
||||||
: getSourceFile().getPath());
|
|
||||||
}
|
}
|
||||||
return meta;
|
return meta;
|
||||||
}
|
}
|
||||||
|
@ -1832,7 +1825,7 @@ public class AnnotationPersistenceMetaDataParser
|
||||||
}
|
}
|
||||||
|
|
||||||
meta.setSource(getSourceFile(), (el instanceof Class) ? el : null,
|
meta.setSource(getSourceFile(), (el instanceof Class) ? el : null,
|
||||||
SourceTracker.SRC_ANNOTATIONS, getSourceFile() == null ? "" : getSourceFile().getPath());
|
SourceTracker.SRC_ANNOTATIONS);
|
||||||
if (isMetaDataMode())
|
if (isMetaDataMode())
|
||||||
meta.setSourceMode(MODE_META);
|
meta.setSourceMode(MODE_META);
|
||||||
else if (isMappingMode())
|
else if (isMappingMode())
|
||||||
|
@ -1909,7 +1902,7 @@ public class AnnotationPersistenceMetaDataParser
|
||||||
meta.addHint(hint.name(), hint.value());
|
meta.addHint(hint.name(), hint.value());
|
||||||
|
|
||||||
meta.setSource(getSourceFile(), (el instanceof Class) ? el : null,
|
meta.setSource(getSourceFile(), (el instanceof Class) ? el : null,
|
||||||
SourceTracker.SRC_ANNOTATIONS, getSourceFile() == null ? "" : getSourceFile().getPath());
|
SourceTracker.SRC_ANNOTATIONS);
|
||||||
if (isMetaDataMode())
|
if (isMetaDataMode())
|
||||||
meta.setSourceMode(MODE_META);
|
meta.setSourceMode(MODE_META);
|
||||||
else if (isMappingMode())
|
else if (isMappingMode())
|
||||||
|
|
|
@ -871,20 +871,12 @@ public class XMLPersistenceMetaDataParser
|
||||||
&& ((isMetaDataMode() && (meta.getSourceMode() & MODE_META) != 0)
|
&& ((isMetaDataMode() && (meta.getSourceMode() & MODE_META) != 0)
|
||||||
|| (isMappingMode() && (meta.getSourceMode() & MODE_MAPPING) != 0)))
|
|| (isMappingMode() && (meta.getSourceMode() & MODE_MAPPING) != 0)))
|
||||||
{
|
{
|
||||||
if(isDuplicateClass(meta)) {
|
if (log.isWarnEnabled())
|
||||||
if (log.isWarnEnabled()) {
|
log.warn(_loc.get("dup-metadata", _cls, getSourceName()));
|
||||||
log.warn(_loc.get("dup-metadata", _cls, getSourceName()));
|
|
||||||
}
|
|
||||||
if(log.isTraceEnabled()) {
|
|
||||||
log.trace(String.format(
|
|
||||||
"MetaData originally obtained from source: %s under mode: %d with scope: %s, and type: %d",
|
|
||||||
meta.getSourceName(), meta.getSourceMode(), meta.getSourceScope(), meta.getSourceType()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_cls = null;
|
_cls = null;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int access = AccessCode.UNKNOWN;
|
int access = AccessCode.UNKNOWN;
|
||||||
if (meta == null) {
|
if (meta == null) {
|
||||||
int accessCode = toAccessType(attrs.getValue("access"));
|
int accessCode = toAccessType(attrs.getValue("access"));
|
||||||
|
@ -904,20 +896,17 @@ public class XMLPersistenceMetaDataParser
|
||||||
meta.setSourceMode(MODE_NONE);
|
meta.setSourceMode(MODE_NONE);
|
||||||
|
|
||||||
// parse annotations first so XML overrides them
|
// parse annotations first so XML overrides them
|
||||||
if (_parser != null) {
|
if (_parser != null)
|
||||||
_parser.parse(_cls);
|
_parser.parse(_cls);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
access = meta.getAccessType();
|
access = meta.getAccessType();
|
||||||
|
|
||||||
boolean mappedSuper = "mapped-superclass".equals(elem);
|
boolean mappedSuper = "mapped-superclass".equals(elem);
|
||||||
boolean embeddable = "embeddable".equals(elem);
|
boolean embeddable = "embeddable".equals(elem);
|
||||||
|
|
||||||
if (isMetaDataMode()) {
|
if (isMetaDataMode()) {
|
||||||
Locator locator = getLocation().getLocator();
|
meta.setSource(getSourceFile(), SourceTracker.SRC_XML);
|
||||||
meta.setSource(getSourceFile(), SourceTracker.SRC_XML, locator != null ? locator.getSystemId() : "" );
|
|
||||||
meta.setSourceMode(MODE_META, true);
|
meta.setSourceMode(MODE_META, true);
|
||||||
|
Locator locator = getLocation().getLocator();
|
||||||
if (locator != null) {
|
if (locator != null) {
|
||||||
meta.setLineNumber(locator.getLineNumber());
|
meta.setLineNumber(locator.getLineNumber());
|
||||||
meta.setColNumber(locator.getColumnNumber());
|
meta.setColNumber(locator.getColumnNumber());
|
||||||
|
@ -1708,7 +1697,7 @@ public class XMLPersistenceMetaDataParser
|
||||||
Object cur = currentElement();
|
Object cur = currentElement();
|
||||||
Object scope = (cur instanceof ClassMetaData)
|
Object scope = (cur instanceof ClassMetaData)
|
||||||
? ((ClassMetaData) cur).getDescribedType() : null;
|
? ((ClassMetaData) cur).getDescribedType() : null;
|
||||||
meta.setSource(getSourceFile(), scope, SourceTracker.SRC_XML, locator == null ? "" : locator.getSystemId());
|
meta.setSource(getSourceFile(), scope, SourceTracker.SRC_XML);
|
||||||
if (isMetaDataMode())
|
if (isMetaDataMode())
|
||||||
meta.setSourceMode(MODE_META);
|
meta.setSourceMode(MODE_META);
|
||||||
else if (isMappingMode())
|
else if (isMappingMode())
|
||||||
|
@ -1791,9 +1780,8 @@ public class XMLPersistenceMetaDataParser
|
||||||
log.trace(_loc.get("parse-native-query", name));
|
log.trace(_loc.get("parse-native-query", name));
|
||||||
|
|
||||||
QueryMetaData meta = getRepository().getCachedQueryMetaData(null, name);
|
QueryMetaData meta = getRepository().getCachedQueryMetaData(null, name);
|
||||||
if (meta != null && isDuplicateQuery(meta) ) {
|
if (meta != null && log.isWarnEnabled())
|
||||||
log.warn(_loc.get("override-query", name, currentLocation()));
|
log.warn(_loc.get("override-query", name, currentLocation()));
|
||||||
}
|
|
||||||
|
|
||||||
meta = getRepository().addQueryMetaData(null, name);
|
meta = getRepository().addQueryMetaData(null, name);
|
||||||
meta.setDefiningType(_cls);
|
meta.setDefiningType(_cls);
|
||||||
|
@ -1813,9 +1801,10 @@ public class XMLPersistenceMetaDataParser
|
||||||
meta.setResultSetMappingName(val);
|
meta.setResultSetMappingName(val);
|
||||||
|
|
||||||
Object cur = currentElement();
|
Object cur = currentElement();
|
||||||
Object scope = (cur instanceof ClassMetaData) ? ((ClassMetaData) cur).getDescribedType() : null;
|
Object scope = (cur instanceof ClassMetaData)
|
||||||
|
? ((ClassMetaData) cur).getDescribedType() : null;
|
||||||
|
meta.setSource(getSourceFile(), scope, SourceTracker.SRC_XML);
|
||||||
Locator locator = getLocation().getLocator();
|
Locator locator = getLocation().getLocator();
|
||||||
meta.setSource(getSourceFile(), scope, SourceTracker.SRC_XML, locator == null ? "" : locator.getSystemId());
|
|
||||||
if (locator != null) {
|
if (locator != null) {
|
||||||
meta.setLineNumber(locator.getLineNumber());
|
meta.setLineNumber(locator.getLineNumber());
|
||||||
meta.setColNumber(locator.getColumnNumber());
|
meta.setColNumber(locator.getColumnNumber());
|
||||||
|
@ -2193,47 +2182,4 @@ public class XMLPersistenceMetaDataParser
|
||||||
protected String normalizeCatalogName(String catName) {
|
protected String normalizeCatalogName(String catName) {
|
||||||
return catName;
|
return catName;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Determines whether the ClassMetaData has been resolved more than once. Compares the current sourceName and
|
|
||||||
* linenumber to the ones used to originally resolve the metadata.
|
|
||||||
*
|
|
||||||
* @param meta The ClassMetaData to inspect.
|
|
||||||
* @return true if the source was has already been resolved from a different location. Otherwise return false
|
|
||||||
*/
|
|
||||||
protected boolean isDuplicateClass(ClassMetaData meta) {
|
|
||||||
if (!StringUtils.equals(getSourceName(), meta.getSourceName())) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (getLineNum() != meta.getLineNumber()) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Determines whether the QueryMetaData has been resolved more than once.
|
|
||||||
* @param meta QueryMetaData that has already been resolved.
|
|
||||||
* @return true if the QueryMetaData was defined in a different place - e.g. another line in orm.xml.
|
|
||||||
*/
|
|
||||||
protected boolean isDuplicateQuery(QueryMetaData meta) {
|
|
||||||
if(! StringUtils.equals(getSourceName(), meta.getSourceName())) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if(getLineNum() != meta.getLineNumber()) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private int getLineNum() {
|
|
||||||
int lineNum = 0;
|
|
||||||
Locator loc = getLocation().getLocator();
|
|
||||||
if(loc != null ) {
|
|
||||||
lineNum = loc.getLineNumber();
|
|
||||||
}
|
|
||||||
return lineNum;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue