如何在jpa spring boot中使用Map作为带分页的查询参数
How to use Map as query paramter with pagination in jpa springboot
如何在带分页的jpa spring boot中使用HashMap>作为查询参数
是的,这是可能的。您可以在查询中使用 Spring 表达式语言。
示例:
@Query("select e from Employee e where e.name = :#{#map.get('name')}")
List<Employee> findEmployees(Map<String, String> map);
甚至更短
@Query("select e from Employee e where e.name = :#{#map['name']}")
List<Employee> findEmployees(Map<String, String> map);
也适用于 IN
@Query("select e from Employee e where e.name in :#{#map['name']}")
List<Employee> findEmployees(Map<String, List<String>> map);
如何在带分页的jpa spring boot中使用HashMap
是的,这是可能的。您可以在查询中使用 Spring 表达式语言。
示例:
@Query("select e from Employee e where e.name = :#{#map.get('name')}")
List<Employee> findEmployees(Map<String, String> map);
甚至更短
@Query("select e from Employee e where e.name = :#{#map['name']}")
List<Employee> findEmployees(Map<String, String> map);
也适用于 IN
@Query("select e from Employee e where e.name in :#{#map['name']}")
List<Employee> findEmployees(Map<String, List<String>> map);