Mybatis中resultType不想写一个Vo类来封装的话,可以直接使用Hashmap
作为resultType;一个Map对象,代表了一条数据,key-value值,代表表字段名和值
在xml中,count查询用select
<select id="count" parameterType="java.lang.String"
resultType="java.lang.Integer">
SELECT COUNT(1) FROM t_order t WHERE t.`open_id`= #{openId}
AND t.`order_status` != #{notConfirmed}
</select>
select、insert、update、delete,增删改查同级
xml中””内的空格不会自动trim掉的
如:resultType="java.lang.Integer"不能写为:resultType="java.lang.Integer "
不使用注解也能传递参数给XML
public HashMap<String, Object> incomeFanchart(Query query);
不用任何注解,
在xml文件中使用#{status}就能直接去到query中的属性值
且,在标签属性里和内容里,取从外部传进来的值的写法不同
属性是在双引号内直接写:“orgCode!=‘all’”
内容是#{orgCode}
<sql id="commonConditionSql">
<if test="orgCode!='all'">
t.`org_code` = #{orgCode}
AND
</if>
DATE(t.`create_date`) >=
#{startDate}
AND
DATE(t.`create_date`) <=
#{endDate}
</sql>
Mybatis语句
<![CDATA[>=]]>
ssd.book_end_time <![CDATA[>=]]>#{date}