mirror of
https://github.com/apache/openjpa.git
synced 2025-02-08 11:06:01 +00:00
OPENJPA-44: Support 'metadata-complete' attribute to ignore class-level annotations.
git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@680520 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
64dbe4c924
commit
9174b3f174
@ -174,6 +174,7 @@ public class XMLPersistenceMetaDataParser
|
|||||||
private Class _listener = null;
|
private Class _listener = null;
|
||||||
private Collection<LifecycleCallbacks>[] _callbacks = null;
|
private Collection<LifecycleCallbacks>[] _callbacks = null;
|
||||||
private int[] _highs = null;
|
private int[] _highs = null;
|
||||||
|
private boolean _isXMLMappingMetaDataComplete = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor; supply configuration.
|
* Constructor; supply configuration.
|
||||||
@ -477,8 +478,10 @@ public class XMLPersistenceMetaDataParser
|
|||||||
}
|
}
|
||||||
} else if (tag == ELEM_PU_META || tag == ELEM_PU_DEF)
|
} else if (tag == ELEM_PU_META || tag == ELEM_PU_DEF)
|
||||||
ret = isMetaDataMode();
|
ret = isMetaDataMode();
|
||||||
else if (tag == ELEM_XML_MAP_META_COMPLETE)
|
else if (tag == ELEM_XML_MAP_META_COMPLETE) {
|
||||||
setAnnotationParser(null);
|
setAnnotationParser(null);
|
||||||
|
_isXMLMappingMetaDataComplete = true;
|
||||||
|
}
|
||||||
else if (tag == ELEM_ACCESS)
|
else if (tag == ELEM_ACCESS)
|
||||||
ret = _mode != MODE_QUERY;
|
ret = _mode != MODE_QUERY;
|
||||||
else if (tag == ELEM_LISTENER)
|
else if (tag == ELEM_LISTENER)
|
||||||
@ -718,16 +721,30 @@ public class XMLPersistenceMetaDataParser
|
|||||||
throws SAXException {
|
throws SAXException {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean isMetaDataComplete(Attributes attrs) {
|
||||||
|
return attrs != null
|
||||||
|
&& "true".equals(attrs.getValue("metadata-complete"));
|
||||||
|
}
|
||||||
|
|
||||||
|
void resetAnnotationParser() {
|
||||||
|
setAnnotationParser(((PersistenceMetaDataFactory)getRepository()
|
||||||
|
.getMetaDataFactory()).getAnnotationParser());
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean startClass(String elem, Attributes attrs)
|
protected boolean startClass(String elem, Attributes attrs)
|
||||||
throws SAXException {
|
throws SAXException {
|
||||||
super.startClass(elem, attrs);
|
super.startClass(elem, attrs);
|
||||||
|
if (isMetaDataComplete(attrs)) {
|
||||||
|
setAnnotationParser(null);
|
||||||
|
} else if (!_isXMLMappingMetaDataComplete){
|
||||||
|
resetAnnotationParser();
|
||||||
|
}
|
||||||
|
|
||||||
// query mode only?
|
// query mode only?
|
||||||
_cls = classForName(currentClassName());
|
_cls = classForName(currentClassName());
|
||||||
if (_mode == MODE_QUERY) {
|
if (_mode == MODE_QUERY) {
|
||||||
if (_parser != null &&
|
if (_parser != null)
|
||||||
!"true".equals(attrs.getValue("metadata-complete")))
|
|
||||||
_parser.parse(_cls);
|
_parser.parse(_cls);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -765,8 +782,7 @@ 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)
|
||||||
!"true".equals(attrs.getValue("metadata-complete")))
|
|
||||||
_parser.parse(_cls);
|
_parser.parse(_cls);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user