mybatis 参数及mybatis返回类型汇总

1、增加

<insert id="insertUserAddress" parameterType="com.api.entity.Address">
		INSERT INTO ADDRESS (ID, RECEIVER, PHONE, PROVINCE, CITY, ADDRESS, ISDEFAULT, ENTER_DATE) 
		VALUES
		(#{userId},#{receiver},#{telphone},#{province},#{city},#{street},#{isDefault},getdate())
	</insert>

2、删除

<delete id="delAddressByUserId" parameterType="map">
		delete from ADDRESS where ID = #{userId} and ROWID = #{rowId}
	</delete>
3、更新
<update id="setAddressDefault" parameterType="string">
		update ADDRESS set ISDEFAULT = 0 where ID = #{userId}
	</update>

4、查询

4.1查询输入参数为string,返回值类型为映射的类

<select id="getUserAdress" parameterType="string"  resultMap="addressResultMap">
		select ID, RECEIVER, PHONE, PROVINCE, CITY, ADDRESS, ISDEFAULT from OS_ADDRESS where ID = #{userId}
	</select>

4.2 查询输入参数为string,返回值map

<select id="listCateGoryNum" parameterType="string" resultType="map">
		select category,num from ORDER_V where id = #{userId}
	</select>

4.3查询输入参数为string,返回string

<select id="getCodeByCodeId" parameterType="string" resultType="string">
		select CODE_VALUE from CODE where CODE_ID=#{codeId}
	</select>

4.4查询输入参数为类,返回string

<select id="getHoustList" parameterType="com.entity.HousePage" resultMap="houseMap"> </select >

4.5查询输入参数为map,返回类

<select id="getHostHouse" parameterType="map"  resultMap="houseMap"></select>

猜你喜欢

转载自blog.csdn.net/weixin_38175213/article/details/80895431