cache not flushing after UPDATE statement

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

cache not flushing after UPDATE statement

Brian Barnett
Here are my settings:

        <settings>
                <setting name="cacheEnabled" value="true"/>
                <setting name="lazyLoadingEnabled" value="true"/>
                <setting name="aggressiveLazyLoading" value="false"/>
                <setting name="multipleResultSetsEnabled" value="false"/>
                <setting name="useColumnLabel" value="true"/>
                <setting name="useGeneratedKeys" value="false"/>
                <setting name="autoMappingBehavior" value="PARTIAL"/>
                <setting name="defaultExecutorType" value="REUSE"/>
                <setting name="defaultStatementTimeout" value="25000"/>
        </settings>


        <mappers>
                <mapper resource = "sysconfig/sqlmaps/UserMapper.xml" />
        </mappers>

Then my UserMapper.xml file looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
    PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
    "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
   
<mapper namespace="com.fincalc.goso.model.dao.UserMapper">
        <cache/>

. SNIP SNIP .

        <update id="inactivateUser" parameterType="map">
         
                UPDATE user SET
                        status=2,
                        date_inactivated = #{dateInactivated}
                WHERE user_id = #{userId}
       
        </update>

        <select id="selectUsersForCustomer" parameterType="map"
resultMap="userResultMap">
                                         
                SELECT *
                FROM user
                WHERE customer_id = #{customerId}
                        <if test="userId gt 0">
                                AND added_by_user_id = #{userId}
                        </if>
           
        </select>



After running inactivateUser, I run selectUsersForCustomer and the cache
gets hit rather than the database getting hit so I don't see the update.

The console shows that the cache was used:
2011-01-18 14:04:58,062 DEBUG
[org.apache.ibatis.cache.decorators.LoggingCache:27] Cache Hit Ratio
[com.fincalc.goso.model.dao.UserMapper]: 0.6363636363636364

Any ideas?

Thanks,
Brian Barnett

Reply | Threaded
Open this post in threaded view
|

Re: cache not flushing after UPDATE statement

Clinton Begin
Administrator
In the same session?

On 2011-01-18, Brian Barnett <[hidden email]> wrote:

> Here are my settings:
>
> <settings>
> <setting name="cacheEnabled" value="true"/>
> <setting name="lazyLoadingEnabled" value="true"/>
> <setting name="aggressiveLazyLoading" value="false"/>
> <setting name="multipleResultSetsEnabled" value="false"/>
> <setting name="useColumnLabel" value="true"/>
> <setting name="useGeneratedKeys" value="false"/>
> <setting name="autoMappingBehavior" value="PARTIAL"/>
> <setting name="defaultExecutorType" value="REUSE"/>
> <setting name="defaultStatementTimeout" value="25000"/>
> </settings>
>
>
> <mappers>
> <mapper resource = "sysconfig/sqlmaps/UserMapper.xml" />
> </mappers>
>
> Then my UserMapper.xml file looks like this:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE mapper
>     PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
>     "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
>
> <mapper namespace="com.fincalc.goso.model.dao.UserMapper">
> <cache/>
>
> . SNIP SNIP .
>
> <update id="inactivateUser" parameterType="map">
>
> UPDATE user SET
> status=2,
> date_inactivated = #{dateInactivated}
> WHERE user_id = #{userId}
>
> </update>
>
> <select id="selectUsersForCustomer" parameterType="map"
> resultMap="userResultMap">
>  
> SELECT *
> FROM user
> WHERE customer_id = #{customerId}
> <if test="userId gt 0">
> AND added_by_user_id = #{userId}
> </if>
>    
> </select>
>
>
>
> After running inactivateUser, I run selectUsersForCustomer and the cache
> gets hit rather than the database getting hit so I don't see the update.
>
> The console shows that the cache was used:
> 2011-01-18 14:04:58,062 DEBUG
> [org.apache.ibatis.cache.decorators.LoggingCache:27] Cache Hit Ratio
> [com.fincalc.goso.model.dao.UserMapper]: 0.6363636363636364
>
> Any ideas?
>
> Thanks,
> Brian Barnett
>
>

--
Sent from my mobile device
Reply | Threaded
Open this post in threaded view
|

RE: cache not flushing after UPDATE statement

Brian Barnett
Yes, it is happening in the same session.

-----Original Message-----
From: [hidden email] [mailto:[hidden email]]
On Behalf Of Clinton Begin
Sent: Tuesday, January 18, 2011 6:59 PM
To: [hidden email]
Subject: Re: cache not flushing after UPDATE statement

In the same session?

On 2011-01-18, Brian Barnett <[hidden email]> wrote:

> Here are my settings:
>
> <settings>
> <setting name="cacheEnabled" value="true"/>
> <setting name="lazyLoadingEnabled" value="true"/>
> <setting name="aggressiveLazyLoading" value="false"/>
> <setting name="multipleResultSetsEnabled" value="false"/>
> <setting name="useColumnLabel" value="true"/>
> <setting name="useGeneratedKeys" value="false"/>
> <setting name="autoMappingBehavior" value="PARTIAL"/>
> <setting name="defaultExecutorType" value="REUSE"/>
> <setting name="defaultStatementTimeout" value="25000"/>
> </settings>
>
>
> <mappers>
> <mapper resource = "sysconfig/sqlmaps/UserMapper.xml" />
> </mappers>
>
> Then my UserMapper.xml file looks like this:
>
> <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE mapper
>     PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
>     "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
>
> <mapper namespace="com.fincalc.goso.model.dao.UserMapper">
> <cache/>
>
> . SNIP SNIP .
>
> <update id="inactivateUser" parameterType="map">
>
> UPDATE user SET
> status=2,
> date_inactivated = #{dateInactivated}
> WHERE user_id = #{userId}
>
> </update>
>
> <select id="selectUsersForCustomer" parameterType="map"
> resultMap="userResultMap">
>  
> SELECT *
> FROM user
> WHERE customer_id = #{customerId}
> <if test="userId gt 0">
> AND added_by_user_id = #{userId}
> </if>
>    
> </select>
>
>
>
> After running inactivateUser, I run selectUsersForCustomer and the
> cache gets hit rather than the database getting hit so I don't see the
update.

>
> The console shows that the cache was used:
> 2011-01-18 14:04:58,062 DEBUG
> [org.apache.ibatis.cache.decorators.LoggingCache:27] Cache Hit Ratio
> [com.fincalc.goso.model.dao.UserMapper]: 0.6363636363636364
>
> Any ideas?
>
> Thanks,
> Brian Barnett
>
>

--
Sent from my mobile device