SpringbooJPA @Query 中引用 in 和like 没有返回值

我正在尝试在Repository中创建一个能够给我产品列表的方法,但是没有返回值。这是我的方法

    public interface ProductRepository extends JpaRepository { 

    @Query(value = "select * from mmall_product m where m.status =1 and m.name like CONCAT('%',?1,'%') and m.category_id in (?2)", nativeQuery = true)
     List findByNameAndCategoryIds(String productName, String categoryIdLists);
    }

在我的navicatfor mysql中,我可以获取数据,这是我的sql语句
select * from mmall_product m where m.status =1 and m.name like CONCAT('%','a','%') and m.category_id in ("100001","100002","100003")

在数据库中可以返回值
我在service层使用的参数是
List productList = productRepository.findByNameAndCategoryIds("a","100001,100002,100003");
但是无法查询出结果
我希望sql查询和springbootjpa 返回的数据是一样的,请问应该修改哪里

阅读 2.3k
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题