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>

 

Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐