JPA 使用 native 进行 in 查询

  • Post author:
  • Post category:其他




JPA使用native方式进行in查询

        String idStr = String.join("','", Arrays.asList("id1", "ids"));
        Query q = em.createNativeQuery("select *" +
                " from user u" +
                " where u.id IN ('" + idStr + "')");

        List result = q.getResultList();
        
        result.forEach(System.out::println);

注:em为

javax.persistence.EntityManager



版权声明:本文为qq_14947845原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。