sql不支持iBATIS2.3。x可以延迟加载java。整数?
正在尝试延迟加载java。土地整数延迟加载属性:
<result property="foo.cnt" column="id" select="getCnt"/>
Sql语句如下所示:
<sql id="sql-getCnt">
SELECT count(*) as cnt
FROM bar b INNER JOIN bar2 b2 on b.id = b2.id
WHERE bar.id=#id#
AND b2.workds IS NULL
</sql>
选择这样做的语句:
<select id="getCnt" parameterClass="int" resultClass="java.lang.Integer">
<include refid="sql-getCnt"/>
</select>
设置:
<settings
enhancementEnabled="true"
errorTracingEnabled="true"
lazyLoadingEnabled="true"
useStatementNamespaces="true"
/>
我认为延迟加载是有效的。但这就是我在日志中看到的: Select count statement goes right after first select statement - this means that lazy loading doesn't work. To ensure nothing reads object fields I force thread sleep for one minute right after querying the object.
整数的延迟加载有多慢?能做到吗
# 1 楼答案
原因是java。整型类是final,所以cglib不能为它创建代理对象。答案是明确而简单的