Mapped Statements collection does not contain value for xxx问题解决方法
生活随笔
收集整理的這篇文章主要介紹了
Mapped Statements collection does not contain value for xxx问题解决方法
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
今天在一次查詢中,發(fā)生了一個(gè)非法參數(shù)異常,提示
Mapped Statements collection does not contain value for cn.edu.sgu.www.mapper.CommentImageMapper.selectByCommentId
一般看到Mapped Statements collection does not contain value for xxx類似的提示就是找不到xxx對應(yīng)的方法,檢查方法是否存在、包名是否正確,這里的問題就是包名不正確導(dǎo)致的。
package cn.edu.sgu.www.fresheveryday.mapper;import cn.edu.sgu.www.fresheveryday.pojo.entity.Comment; import cn.edu.sgu.www.fresheveryday.pojo.vo.CommentVO; import cn.edu.sgu.www.fresheveryday.pojo.vo.UserSimpleVO; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import org.apache.ibatis.annotations.Many; import org.apache.ibatis.annotations.One; import org.apache.ibatis.annotations.Result; import org.apache.ibatis.annotations.Select; import org.springframework.stereotype.Repository;import java.util.List;@Repository public interface CommentMapper extends BaseMapper<Comment> {/*** 通過商品id查詢評論* @param productId 商品id* @return List<CommentVO>*/@Select("select id, content, type, user_id, comment_id, created from comment where product_id = #{productId}")@Result(column = "id", property = "id")@Result(column = "comment_id", property = "commentId")@Result(column = "id", property = "images",many = @Many(select = "cn.edu.sgu.www.mapper.CommentImageMapper.selectByCommentId"))@Result(column = "user_id", property = "user", javaType = UserSimpleVO.class,one = @One(select = "cn.edu.sgu.www.fresheveryday.mapper.UserMapper.selectSimpleUserById"))List<CommentVO> selectByProductId(int productId); }這里是因?yàn)樯倭艘粚觙resheveryday包,修改之后的代碼能正常運(yùn)行
package cn.edu.sgu.www.fresheveryday.mapper;import cn.edu.sgu.www.fresheveryday.pojo.entity.Comment; import cn.edu.sgu.www.fresheveryday.pojo.vo.CommentVO; import cn.edu.sgu.www.fresheveryday.pojo.vo.UserSimpleVO; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import org.apache.ibatis.annotations.Many; import org.apache.ibatis.annotations.One; import org.apache.ibatis.annotations.Result; import org.apache.ibatis.annotations.Select; import org.springframework.stereotype.Repository;import java.util.List;@Repository public interface CommentMapper extends BaseMapper<Comment> {/*** 通過商品id查詢評論* @param productId 商品id* @return List<CommentVO>*/@Select("select id, content, type, user_id, comment_id, created from comment where product_id = #{productId}")@Result(column = "id", property = "id")@Result(column = "comment_id", property = "commentId")@Result(column = "id", property = "images",many = @Many(select = "cn.edu.sgu.www.fresheveryday.mapper.CommentImageMapper.selectByCommentId"))@Result(column = "user_id", property = "user", javaType = UserSimpleVO.class,one = @One(select = "cn.edu.sgu.www.fresheveryday.mapper.UserMapper.selectSimpleUserById"))List<CommentVO> selectByProductId(int productId); }好了,文章就分享到這里了,感謝閱讀~
總結(jié)
以上是生活随笔為你收集整理的Mapped Statements collection does not contain value for xxx问题解决方法的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: hadoop 各种概念整理
- 下一篇: 重庆电信强化线上渠道基础管理