springcloud在实现其查询功能时,其自动生成sql语句,只用写相应的方法名及参数即可,在执行复杂sql语句时,需手写sql语句,其语法规则如下:

@Query(value = "SELECT * FROM *** an WHERE an.id = ?1 AND "
+ "an.status &2 !=2 ORDER BY (an.status &1) DESC;", nativeQuery = true)
List<AlumniNotice> findByAl(String id);

其表示查询结果为list数组;an.id = ?1  表示an.id获取findByA方法中的第一个参数;中间可加入其它过滤条件,案例中添加的是位运算过滤条件。

nativeQuery = true  表示可以使用原生SQL进行查询

 

posted on 2018-12-19 00:03  qqzhulu  阅读(772)  评论(0编辑  收藏  举报