Skip to content

Commit

Permalink
Lazy loading defaults to false. Fix for http://code.google.com/p/myba…
Browse files Browse the repository at this point in the history
  • Loading branch information
emacarron committed Dec 25, 2010
1 parent df0f135 commit f8ddba3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ private void settingsElement(XNode context) throws Exception {
}
configuration.setAutoMappingBehavior(AutoMappingBehavior.valueOf(stringValueOf(props.getProperty("autoMappingBehavior"), "PARTIAL")));
configuration.setCacheEnabled(booleanValueOf(props.getProperty("cacheEnabled"), true));
configuration.setLazyLoadingEnabled(booleanValueOf(props.getProperty("lazyLoadingEnabled"), safeCglibCheck()));
configuration.setLazyLoadingEnabled(booleanValueOf(props.getProperty("lazyLoadingEnabled"), false));
configuration.setAggressiveLazyLoading(booleanValueOf(props.getProperty("aggressiveLazyLoading"), true));
configuration.setMultipleResultSetsEnabled(booleanValueOf(props.getProperty("multipleResultSetsEnabled"), true));
configuration.setUseColumnLabel(booleanValueOf(props.getProperty("useColumnLabel"), true));
Expand All @@ -163,14 +163,6 @@ private void settingsElement(XNode context) throws Exception {
}
}

private boolean safeCglibCheck() {
try {
return Resources.classForName("net.sf.cglib.proxy.Enhancer") != null;
} catch (Exception e) {
return false;
}
}

private void environmentsElement(XNode context) throws Exception {
if (context != null) {
if (environment == null) {
Expand Down
10 changes: 9 additions & 1 deletion src/main/java/org/apache/ibatis/session/Configuration.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.apache.ibatis.executor.statement.RoutingStatementHandler;
import org.apache.ibatis.executor.statement.StatementHandler;
import org.apache.ibatis.io.ResolverUtil;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.mapping.*;
import org.apache.ibatis.parsing.XNode;
import org.apache.ibatis.plugin.Interceptor;
Expand Down Expand Up @@ -131,6 +132,13 @@ public boolean isLazyLoadingEnabled() {
}

public void setLazyLoadingEnabled(boolean lazyLoadingEnabled) {
if (lazyLoadingEnabled) {
try {
Resources.classForName("net.sf.cglib.proxy.Enhancer");
} catch (Throwable e) {
throw new IllegalArgumentException("Cannot enable lazy loading because CGLIB is not available. Add CGLIB to your classpath.", e);
}
}
this.lazyLoadingEnabled = lazyLoadingEnabled;
}

Expand Down Expand Up @@ -525,7 +533,7 @@ protected void checkLocallyForDiscriminatedNestedResultMaps(ResultMap rm) {
}
}
}

protected static class StrictMap<J extends String, K extends Object> extends HashMap<J, K> {

private String name;
Expand Down

0 comments on commit f8ddba3

Please sign in to comment.