ibatis 2.3.x可以懒加载吗java.lang.Integer?

Does ibatis 2.3.x can lazy load java.lang.Integer?

正在尝试延迟加载 java.land.Integer。延迟加载 属性:

<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 这样的语句:

<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.

Integer 的延迟加载如何实现?完全可以做到吗?

原因是 java.lang.Integer class 是最终的,所以 cglib 不能为它创建代理对象。答案简单明了。