0 0

关于Mybats的缓存。0

Mybatis的缓存,在执行insert,update,delete语句时会自动清空缓存。
但是在一对多的情况下。为什么在多的一方执行插入删除更新时,不清空缓存?


<?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="xx.Dao.ServerInfoDao">
   	<cache
      eviction="FIFO"
      flushInterval="6000000"
      size="1024"
      readOnly="true" >      
      </cache>  
 
   <resultMap type="xx.Model.Server" id="ServersMap">   		      	     
		<id property="serverId"			 	column="ServerId" />
		<result property="ipAddress"			column="IPAddress" />
		<result property="serverName"			column="ServerName" />    	
    	<collection property="positions" column="{id=ServerId,user=username}" select="getPositionsById"/>    	
	</resultMap>
	
	<resultMap type="xx.Model.ServerPosition" id="positionMap">						
		<id property="x1" column="x1" />
		<id property="x2" column="x2" />						
		<result property="x" column="x" />
		<result property="y" column="y" />								
    </resultMap>
		
    <select id="SelectServer"   resultMap="ServersMap"  statementType="CALLABLE">
		SELECT * FROM ServerInfo
    </select>
        
	<select id="getPositionsById" resultMap="positionMap"> 
		SELECT * FROM ServerPosition
		WHERE  UserName=#{user} AND
			   ServerId=#{id}  
  	</select>      
    
	<insert id="InsertServer" statementType="CALLABLE" parameterType="xx.Model.Server">    	 
		INSERT INTO [ServerInfo]([ServerID],[IPAddress],[ServerName])
            VALUES (#{serverId},#{ipAddress},#{serverName});
    </insert>        	
	
 	<update id="UpdateServer" statementType="CALLABLE" parameterType="xx.Model.Server">    	 
		UPDATE [ServerInfo]
   		SET [ServerName] = #{serverName}
      		[IPAddress] = #{ipAddress},      		      		
 		WHERE  [ServerID] = #{serverId}; 
    </update>
	
 	<delete id="DeleteServer" statementType="CALLABLE" parameterType="java.lang.Integer" >
		DELETE FROM [ServerInfo] WHERE  [ServerID] = #{serverId};
    </delete>
    
    <insert  id="InsertPosition" statementType="CALLABLE" >
    	INSERT INTO ServerPosition 
    	SELECT #{0},#{1},#{2},#{3}
    </insert>

    <delete  id="DeletePosition" statementType="CALLABLE" >
    	DELETE FROM ServerPosition 
    	WHERE   [x1]=#{0} AND
    			[x2]=#{1}
    </delete>
       
</mapper>



执行上面配置文件中的InsertPosition和DeletePosition没法清空缓存?这是为什么呢?
2014年4月24日 17:37
目前还没有答案

相关推荐

Global site tag (gtag.js) - Google Analytics