Skip to content

Commit b893124

Browse files
committed
Using fethType in xml for consistency.
1 parent 312babd commit b893124

File tree

5 files changed

+8
-10
lines changed

5 files changed

+8
-10
lines changed

src/main/java/org/apache/ibatis/builder/xml/XMLMapperBuilder.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -364,14 +364,14 @@ private ResultMapping buildResultMappingFromContext(XNode context, Class<?> resu
364364
String typeHandler = context.getStringAttribute("typeHandler");
365365
String resulSet = context.getStringAttribute("resultSet");
366366
String foreignColumn = context.getStringAttribute("foreignColumn");
367-
boolean lazy = context.getBooleanAttribute("lazy", configuration.isLazyLoadingEnabled());
367+
boolean lazy = "lazy".equals(context.getStringAttribute("fetchType", configuration.isLazyLoadingEnabled() ? "lazy" : "eager"));
368368
Class<?> javaTypeClass = resolveClass(javaType);
369369
@SuppressWarnings("unchecked")
370370
Class<? extends TypeHandler<?>> typeHandlerClass = (Class<? extends TypeHandler<?>>) resolveClass(typeHandler);
371371
JdbcType jdbcTypeEnum = resolveJdbcType(jdbcType);
372372
return builderAssistant.buildResultMapping(resultType, property, column, javaTypeClass, jdbcTypeEnum, nestedSelect, nestedResultMap, notNullColumn, columnPrefix, typeHandlerClass, flags, resulSet, foreignColumn, lazy);
373373
}
374-
374+
375375
private String processNestedResultMappings(XNode context, List<ResultMapping> resultMappings) throws Exception {
376376
if ("association".equals(context.getName())
377377
|| "collection".equals(context.getName())

src/main/java/org/apache/ibatis/builder/xml/mybatis-3-mapper.dtd

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ columnPrefix CDATA #IMPLIED
117117
resultSet CDATA #IMPLIED
118118
foreignColumn CDATA #IMPLIED
119119
autoMapping (true|false) #IMPLIED
120-
lazy (true|false) #IMPLIED
120+
fetchType (lazy|eager) #IMPLIED
121121
>
122122

123123
<!ELEMENT association (constructor?,id*,result*,association*,collection*, discriminator?)>
@@ -134,7 +134,7 @@ columnPrefix CDATA #IMPLIED
134134
resultSet CDATA #IMPLIED
135135
foreignColumn CDATA #IMPLIED
136136
autoMapping (true|false) #IMPLIED
137-
lazy (true|false) #IMPLIED
137+
fetchType (lazy|eager) #IMPLIED
138138
>
139139

140140
<!ELEMENT discriminator (case+)>

src/main/java/org/apache/ibatis/executor/resultset/DefaultResultSetHandler.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import org.apache.ibatis.executor.loader.ProxyFactory;
3434
import org.apache.ibatis.executor.loader.ResultLoader;
3535
import org.apache.ibatis.executor.loader.ResultLoaderMap;
36+
import org.apache.ibatis.executor.loader.cglib.CglibProxyFactory;
3637
import org.apache.ibatis.executor.parameter.ParameterHandler;
3738
import org.apache.ibatis.executor.result.DefaultResultContext;
3839
import org.apache.ibatis.executor.result.DefaultResultHandler;
@@ -94,7 +95,7 @@ public DefaultResultSetHandler(Executor executor, MappedStatement mappedStatemen
9495
this.typeHandlerRegistry = configuration.getTypeHandlerRegistry();
9596
this.objectFactory = configuration.getObjectFactory();
9697
this.resultHandler = resultHandler;
97-
this.proxyFactory = configuration.getProxyFactory();
98+
this.proxyFactory = configuration.getProxyFactory() == null ? new CglibProxyFactory() : configuration.getProxyFactory();
9899
}
99100

100101
//

src/main/java/org/apache/ibatis/session/Configuration.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -292,9 +292,6 @@ public void setLazyLoadingEnabled(boolean lazyLoadingEnabled) {
292292
}
293293

294294
public ProxyFactory getProxyFactory() {
295-
if (proxyFactory == null) {
296-
proxyFactory = new CglibProxyFactory();
297-
}
298295
return proxyFactory;
299296
}
300297

src/test/java/org/apache/ibatis/builder/BlogMapper.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@
5858
<resultMap id="blogWithPostsLazy" type="Blog">
5959
<id property="id" column="id"/>
6060
<result property="title" column="title"/>
61-
<association property="author" column="author_id" select="domain.blog.mappers.AuthorMapper.selectAuthorWithInlineParams" lazy="true"/>
62-
<collection property="posts" column="id" select="selectPostsForBlog" lazy="true"/>
61+
<association property="author" column="author_id" select="domain.blog.mappers.AuthorMapper.selectAuthorWithInlineParams" fetchType="lazy"/>
62+
<collection property="posts" column="id" select="selectPostsForBlog" fetchType="lazy"/>
6363
</resultMap>
6464

6565
<select id="selectBlogWithPostsUsingSubSelectLazily" parameterType="int" resultMap="blogWithPostsLazy">

0 commit comments

Comments
 (0)