1.在,一個對象的mapper中:
<mapper namespace="Pluto.Dao.inter.PlutoOperation">
自定義一個resultmap
<resultMap type="Music" id="resultListMusic">
<result column="id" property="id" />
<result column="title" property="title" />
</resultMap>
調用上面的resultmap
<select id="SeachMusicByDESC" resultMap="resultListMusic">
select * from music order by id DESC
</select>
</mapper>
這里返回的是一個list對象,在mybatis中,沒有resultset這個對象
2.在需要傳入多個參數的時候,select組中就不需要明確指出參數的類型了,需要在下文中sql語句,通過index來表明傳入的變量
<select id="JudgeadminNameAndPwd" resultType="ResultSet">
select * from admin where adminName = #{0} and adminPwd = #{1}
</select>
3。發現一個驚天 bug,對于3.0.4版本的mybatis.jar,會有可能出現這種錯誤:
[mybatis IllegalArgumentException:
Mapped Statements collection does not contain value]
這個問題整整刁難了我一個下午,本來以為是xml文件路徑不對,mapper映射錯誤,方法名與xml文件中的id不對應,結果都不是。
問題出在jar包身上,在stackoverflow搜了好長時間,發現這一句,然后換了jar包之后,問題迎刃而解
This error sometime appears on the first query with MyBatis 3.0.4. This is fixed in 3.0.5-SNAPHOT.
來源:http://mybatis-user.963551.n3.nabble.com/Mapped-Statements-collection-does-not-contain-value-td2553948.html