简体   繁体   中英

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

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM