Default settings for attributes in <settings> element doesn't take effect if
the element is missed in SqlMapConfig file
-----------------------------------------------------------------------------------------------------------------------
Key: IBATIS-561
URL: https://issues.apache.org/jira/browse/IBATIS-561
Project: iBatis for Java
Issue Type: Bug
Components: SQL Maps
Affects Versions: 2.3.4
Environment: not relevent
Reporter: YinXin He
I currently use ibatis-2.3.4 and find that the <settings> element in
SqlMapConfig.xml shouldn't missed if you want the default settings in this tag
to take effect even if you don't put any attributes in it.In other words,if you
don't leave the <settings> element in SqlMapConfig.xml,all the boolean
attributes(like cacheModelsEnabled,lazyLoadingEnabled) will be false instead of
the default value as said by the docs(cacheModelsEnabled,lazyLoadingEnabled are
both setted as true defaultly according to the docs) .
After digging into the source code,i find the "processNodelet" method in
NodeletParser class is the one to call the "process" method of the nodelet
interface
which actually parses all the elements in the config file,just as the follwing
codes:
private void processNodelet(Node node, String pathString) {
Nodelet nodelet = (Nodelet) letMap.get(pathString);
if (nodelet != null) {
try {
nodelet.process(node);
} catch (Exception e) {
throw new RuntimeException("Error parsing XPath '" + pathString + "'.
Cause: " + e, e);
}
}
}
so if the <settings> element doesn't exist in SqlMapConfig file,then the
processNodelet method will never be called,then the process method for dealing
with settings attributes will not be called either,thus all the boolean
attributes will be the value "false" instead of the default values(many of
them are true defaultly like the cacheModelsEnabled attribute) specified by
the docs.
Maybe a simple way to solve this problem is to initialize all the relevent
attributes in SqlMapExecutorDelegate class to the default setting value
according to the docs like the code segment below to prevent it from being
setted as the default initial value "false" in case the <setting> element is
missing.
public class SqlMapExecutorDelegate {
private static final Probe PROBE = ProbeFactory.getProbe();
private boolean lazyLoadingEnabled=true;
private boolean cacheModelsEnabled=true;
private boolean enhancementEnabled=true;
private boolean useColumnLabel = true;
private boolean forceMultipleResultSetSupport=true;
private boolean statementCacheEnabled=true;
...
}
Thanks
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.