mybatis saveOrUpdate


	<insert id="saveOrUpdate" >
		<selectKey keyProperty="count" resultType="int" order="BEFORE">
			SELECT COUNT(1) FROM xxxxtable WHERE xxid= #{xxid}
		</selectKey>
		<if test="count > 0">
			update xxxxtable set xxxa=#{xxxa},xxxb=#{xxxb},xxxc=#{xxxc} where xxid= #{xxid}
		</if>
		<if test="count==0">
			INSERT INTO xxxxtable (xxid,xxxa,xxxb,xxxc) VALUES (#{xxid},#{xxxa},#{xxxb},#{xxxc})
		</if>
	</insert>

你可能感兴趣的:(mybatis)