OPENJPA-2011: Optionally prevent reparsing annotations in in query mode.

git-svn-id: https://svn.apache.org/repos/asf/openjpa/branches/2.1.x@1151637 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael Dick 2011-07-27 21:32:34 +00:00
parent 7db9f3dc7e
commit dddb5a0f67
2 changed files with 29 additions and 4 deletions

View File

@ -68,7 +68,7 @@ public class Compatibility {
private boolean _ignoreDetachedStateFieldForProxySerialization = false;
private boolean _convertPositionalParametersToNamed = false;
private boolean _checkDatabaseForCascadePersistToDetachedEntity = true;
private boolean _parseAnnotationsForQueryMode = true;
/**
* Whether to require exact identity value types when creating object
* ids from a class and value. Defaults to false.
@ -567,4 +567,26 @@ public class Compatibility {
public void setCheckDatabaseForCascadePersistToDetachedEntity(boolean b){
_checkDatabaseForCascadePersistToDetachedEntity = b;
}
/**
* Whether OpenJPA will scan every persistent class in an XML mapping file for annotations prior to executing a
* query. In practice this scan is rarely needed, but the option to enable it is present for compatibility with
* prior releases.
* @since 2.0.2
* @return true if the annotations should be re-parsed when resolving MetaData in MODE_QUERY.
*/
public boolean getParseAnnotationsForQueryMode() {
return _parseAnnotationsForQueryMode;
}
/**
* Whether OpenJPA will scan every persistent class in an XML mapping file for annotations prior to executing a
* query. In practice this scan is rarely needed, but the option to enable it is present for compatibility with
* prior releases.
* @since 2.0.2
*/
public void setParseAnnotationsForQueryMode(boolean parseAnnotationsForQueryMode) {
_parseAnnotationsForQueryMode = parseAnnotationsForQueryMode;
}
}

View File

@ -856,10 +856,13 @@ public class XMLPersistenceMetaDataParser
}
if (_mode == MODE_QUERY) {
if (_parser != null)
if(_conf.getCompatibilityInstance().getParseAnnotationsForQueryMode()) {
if (_parser != null) {
_parser.parse(_cls);
}
return true;
}
}
Log log = getLog();
if (log.isTraceEnabled())