Map<String, Long> map = new HashMap<String, Long>();
long userId = 1;
long paperId = 1;
map.put("userId", userId);
map.put("paperId",paperId);
session.update(
"com.mukitech.anji.bean.UserPaperMapper.updateStatus", map);
session.commit();
map保存传入参数,传入参数名为key,值为value
<update id="updateStatus" parameterType="java.util.Map">
update user_paper set status=1 where user_id=#{userId} and paper_id = #{paperId}
</update>
user,papers,user_paper为中间表,与user_id和paper_id主键关联
带子条件的内联查询
<select id="selectPaperByUserId" parameterType="java.lang.Long" resultMap="BaseResultMap">
select * from papers p join user_paper up on p.paper_id = up.paper_idjoin users u on u.user_id=up.user_id where u.user_id = #{userId} and up.status=0
</select>