解决Mybatis出现的各种Parameter ' ' not found. Available parameters are [ , ]
·
1.当Mapper给xml传入的是基础类型或者要用到的list时,出现问题的原因可能是因为Mapper的参数没有加@Param标注
List<UserMissionRecord> getMissionRecordByUserIds(@Param("userIdList") List<Long> userIdList);
UserMissionRecord getIsDoneMissionRecordByUserIdAndMissionId(@Param("userId") long userId, @Param("missionId") int missionId);
2.当传入的为一个对象,xml中直接取了对象中的属性时,则不需要加@Param标注
int addUserMissionRecord(UserMissionRecord userMissionRecord);
<select id="getMissionRecordByUserIds" resultType="com.beibei.mission.UserMissionRecord">
SELECT
<include refid="FIELDS"/>
FROM
<include refid="TABLE"/>
WHERE
user_id in
<foreach collection="userIdList" open="(" close=")" separator="," item="userId" >
#{userId}
</foreach>
and is_delete = 0
</select>
<select id="getIsDoneMissionRecordByUserIdAndMissionId" resultType="com.beibei.mission.UserMissionRecord">
SELECT
<include refid="FIELDS"/>
FROM
<include refid="TABLE"/>
WHERE
user_id = #{userId}
and mission_id = #{missionId}
and is_done = 1
and is_delete = 0
</select>
<insert id="addUserMissionRecord" parameterType="com.beibei.mission.UserMissionRecord">
insert into
<include refid="TABLE"/>
(user_id,mission_id,is_done,reward)
values
(#{userId},#{missionId},#{isDone},#{reward})
</insert>
更多推荐
已为社区贡献1条内容
所有评论(0)