PageRequest pageable = PageRequest.of(page, limit,new Sort(Direction.DESC,"XXX").and(new Sort(Direction.DESC,"XXX")));
1. 动态Where条件查询
注意如果有动态where,而且没有一项确定的值,需要加where 1=1
如果不为空查询,为空不查询
@Query(value = "select * from bug_data where if(?3 !='',bug_level=?3 ,1=1 )
and if(?2 !='',bug_type=?2 ,1=1 ) and if(?1 !='',LOCATE(?1, bug_name)>0,1=1 ) ",
nativeQuery = true)
public Page<BugData> dongtai3(@Param("bugName") String bugName,
@Param("bugType") String bugType,
@Param("bugLevel") String bugLevel, Pageable pageable);
@Query(value = "select * from xxxx where if(?3 !='',a=?3 ,1=1 )
and if(?2 !='',b=?2 ,