在这里就推荐 参考链接https://github.com/fujiangwei/springboot-learn/tree/master/springboot-jpa  ,可以访问这个链接有详细介绍。

注意:如果是ssh框架做模糊查询的时候,最好是自己写HQL语句,要不然出不了数据,反正我试过了。

ssh框架的HQL例子:

@Query("SELECT it FROM magneto.Xmgl it WHERE it.ztId=?1 and it.listType=?2 and it.name like %?3% and it.projectCode like %?4%")
Page<Xmgl> findAllByZtIdAndListTypeAndNameLikeAndProjectCodeLike(int ztId, ListType listType, String name, String projectCode, Pageable pageable);

@Query("SELECT count(it.id) FROM magneto.Xmgl it WHERE it.ztId=?1 and it.listType=?2 and it.name like %?3% and it.projectCode like %?4%")
long countByZtIdAndListTypeAndNameLikeAndProjectCodeLike(int ztId, ListType listType, String name, String projectCode);
  • 不能in一个空集合,oracle的in集合的长度不能超过1000;可以like '%%';
  • Between是左右都闭合,相当于:字段 >=左边数 And 字段<=右边数;
  • LessThan表示<,LessThanEqual表示<=,GreaterThan表示>,GreaterThanEqual表示>=;
  • 拿第一条数据可以findTop1By...;
  • 多条件查询其中有个字段是有or关系的,建议写hql吧,这样简单的,要不然,比如 A and B and (C或者 D),写成jpa形式:findAllByAAndBAndCOrAAndBAndD,条件少还行,条件多了就写到烦。