欢迎来到LYBLaoInB的博客
LYBLaoInB
LYBLaoInB
回首往事,不因虚度年华而悔恨,不因碌碌无为而愧疚

mybatis的mapper映射配置文件的sql有几条约定的规则

1.resultType和parameterType都只能写一个值,不过需要很多参数的时候是可以用集合等来作为类型的

2.如果是八个基本类型+String的简单类型,则在参数上可以用任意占位符#{x'x'x},但如果是对象的话要用#{属性值}

3.无论返回结果是一个还是多个,resultType都只能写对象类型,不可以是list什么的。直接用List接受就可以了

 

<insert id="insertPerson" parameterType="com.mybatis.entity.Person">
insert into person(pid,pname,page) values(#{pid},#{pname},#{page})
</insert>
<delete id="deletePersonById" parameterType="Integer">
delete from person where pid=#{anyId}
</delete>
<update id="updatePerson" parameterType="com.mybatis.entity.Person">
update person set pname=#{pname},page=#{page} where pid=#{pid}
</update>
<select id="queryPersonById" resultType="com.mybatis.entity.Person" parameterType="Integer">
select * from person where pid = #{id}
</select>
<select id="queryAll" resultType="com.mybatis.entity.Person">
select * from person
</select>

posted @ 2019-06-10 13:52  LiuYongbo  阅读(388)  评论(0)    收藏  举报
<--将网易云歌单中的id复制到上面的data-id中就可以了 http://music.163.com/playlist?id=3103841025&userid=1698529278 -->