美文网首页
mybatis xml学习

mybatis xml学习

作者: 回不去的那些时光 | 来源:发表于2020-04-12 18:13 被阅读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>

相关文章

网友评论

      本文标题:mybatis xml学习

      本文链接:https://www.haomeiwen.com/subject/osebmhtx.html