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

Viewed 66

Trying to lazy load java.land.Integer. Lazy loaded propery:

<result property="foo.cnt" column="id" select="getCnt"/>

Sql statement done like this:

<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 statement done like this:

<select id="getCnt" parameterClass="int" resultClass="java.lang.Integer">
    <include refid="sql-getCnt"/>
</select>

Settings:

<settings 
    enhancementEnabled="true"
    errorTracingEnabled="true"
    lazyLoadingEnabled="true"
    useStatementNamespaces="true"
/>

I expect that lazy loading works. But that is what i see in logs: 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.

How lazy loading for Integer can be done? Can it be done at all?

1 Answers

The reason is that the java.lang.Integer class is final so cglib can't create proxy object for it. The answer is clear and simple.

Related