我正在尝试在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 返回的数据是一样的,请问应该修改哪里