基于contains子句选择实体的JPA查询不起作用

sqserrrh  于 5个月前  发布在  其他
关注(0)|答案(1)|浏览(102)
Country.java 
  String state;
  String city;

字符串
我们想查询所有包含某个关键字(select * from countries where state=<state> and city like %Ch%)的条目

Page<List<Country>> findByStateAndCityContainingIgnoreCase(String state, String city, Pageable pageable);


上面的查询不是从数据库中获取结果,我们期望JPA构造正确的查询,但我们总是得到空结果

ttcibm8c

ttcibm8c1#

Page里面有一个元素列表。你可以通过getContent()方法访问它。所以返回Page而不是Page<List>

Page<Country> findByStateAndCityContainingIgnoreCase(String state, String city, Pageable pageable);

字符串

相关问题