一、入参方式
1.paramerType:
(1)可接受变量,对象,map(最常用)集合,比如一个单独的字符串或者整数型时,在pramaType中直接写上该类型在java中的全局路径即可
<select id="r" resultMap="BaseResultMap" parameterType="java.util.Map">
<select id="r" resultMap="BaseResultMap" parameterType="java.Lang.Integer">
<select id="r" resultMap="BaseResultMap" parameterType="类的全局路径">(取值存值麻烦,以后尽量少用!!!)
where cerator=#{creator,jdbcType=VARCHAR} 当取传入的参数值时,一定要在其后加上对应字段所在数据库的类型
2paramerMap:基本已不用,已经被.paramerType代替
二、出参方式
1.resultMap
对结果为比较复杂的对象,比如返回对象中包含有其他对象对应的属性或者包含其他对象的数组和集合时,多用此方式来接收!
<resultMap id="bsSiteManageVoMap" type="com.ffnt.server.saasBasicData.service.bo.BsSiteManageBo">
<id column="ID" jdbcType="INTEGER" property="id" />
<result column="creator" jdbcType="VARCHAR" property="creator" />
<result column="longitude" jdbcType="VARCHAR" property="longitude" />
<result column="latitude" jdbcType="VARCHAR" property="latitude" />
<result column="state" jdbcType="VARCHAR" property="state" />
</resultMap>
<select id="r" resultMap="bsSiteManageVoMap" parameterType="java.util.Map">
2.resultType
当查询的结果为简单的变量时,多用此方式接收,单独的对象也可此接受,但扩展性较差,建议对象使用resultMap接收
<select id="r" resultType="java.lang.Integer" parameterType="java.util.Map">