Invalid bound statement (not found)

cart.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.imooc.mall.mapper.CartMapper">
<select id="selectProductList" parameterType="Integer" resultType="com.imooc.mall.vo.CartVO">
SELECT
a.id as id,
a.product_id as productId,
a.user_id as userId,
a.quantity as quantity,
a.selected as selected,
b.price as price,
b.name AS productName,
b.image AS productImage
FROM
imooc_mall_cart a
LEFT JOIN imooc_mall_product b ON a.product_id = b.id
WHERE
a.user_id = #{userId}
AND b.STATUS = 1
</select>
</mapper>CartMapper.java
@Repository
public interface CartMapper extends BaseMapper<Cart> {
List<CartVO> selectProductList(@Param("userId") Integer userId);
}CartServiceImpl.java
@Service
public class CartServiceImpl implements CartService {
@Autowired
private CartMapper cartMapper;
@Autowired
private ProductMapper productMapper;
@Override
public List<CartVO> list(Integer userId) {
List<CartVO> cartVOS = cartMapper.selectProductList(userId);
for (int i = 0; i < cartVOS.size(); i++) {
CartVO cartVO = cartVOS.get(i);
cartVO.setTotalPrice(cartVO.getPrice() * cartVO.getQuantity());
}
return cartVOS;
}
@Override
public List<CartVO> add(Integer productId, Integer count) {
validProduct(productId, count);
QueryWrapper<Cart> qw = new QueryWrapper<>();
qw.eq("product_id", productId);
qw.eq("user_id", UserFilter.loginUser.getId());
Cart cart = cartMapper.selectOne(qw);
if (cart == null) {
cart = new Cart();
cart.setProductId(productId);
cart.setUserId(UserFilter.loginUser.getId());
cart.setQuantity(count);
cart.setSelected(Constant.Cart.SELECTED);
cartMapper.insert(cart);
} else {
cart.setQuantity(cart.getQuantity() + count);
cartMapper.updateById(cart);
}
return this.list(UserFilter.loginUser.getId());
}
private void validProduct(Integer productId,Integer count) {
QueryWrapper<Product> qw = new QueryWrapper<>();
qw.eq("id", productId);
Product product = productMapper.selectOne(qw);
if (product == null || product.getStatus().equals(Constant.SaleStatus.NOT_SALE)) {
throw new ImoocMallException(ImoocMallExceptionEnum.NOT_SALE);
}
if (count > product.getStock()) {
throw new ImoocMallException(ImoocMallExceptionEnum.NOT_ENOUGH);
}
}
}没搞懂,问题出那了
用Mybatis-plus内置的查询是可以的,自定义查询就报错
29
收起
正在回答 回答被采纳积分+1
java工程师2020版
- 参与学习 人
- 提交作业 9410 份
- 解答问题 16556 个
综合就业常年第一,编程排行常年霸榜,无需脱产即可学习,北上广深月薪过万 无论你是未就业的学生还是想转行的在职人员,不需要基础,只要你有梦想,想高薪
了解课程





恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧
0 星