sunny123456

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

JPA使用in查询构建sql参数问题
https://blog.csdn.net/b308175181/article/details/100744622

jpa 自己构建的sql语句,如要使用in,传参必须用List数组,会自动转化。拼接的String类型 只能查出一条记录 。
例子:
@Query(value = “select sa.* from rm_specialactivity sa where sa.id in (?1) and state =1”, nativeQuery= true)
List getSpecialList(List ids); // 可以查出多条
List getSpecialList(String ids);//"2,3,4"拼接的只能查出1条

posted on 2023-03-23 18:57  sunny123456  阅读(419)  评论(0编辑  收藏  举报