mybatis xml学习

2020-04-12  本文已影响0人  回不去的那些时光

核心知识

<select id="selectPerson" parameterType="int" resultType="hashmap">
  SELECT * FROM PERSON WHERE ID = #{id}
</select>

insert, updatedeleteselect差不多

比较重要的属性
id 在命名空间中唯一的标识符,可以被用来引用这条语句。
parameterType 为参数
resultType 为返回结果
resultMap 结果映射, resultType 和 resultMap 之间只能同时使用一个

动态sql

if

<select id="findActiveBlogWithTitleLike"
     resultType="Blog">
  SELECT * FROM BLOG
  WHERE state = ‘ACTIVE’
  <if test="title != null">
    AND title like #{title}
  </if>
</select>
上一篇 下一篇

猜你喜欢

热点阅读