spring-data-jpa通过解析方法名进行条件查询

public interface RecruitDao extends JpaRepository<Recruit,String>,JpaSpecificationExecutor<Recruit>{
    /**
     * 查询推荐职位降序排序,查询前六条
     * @param state
     * @return
     * SELECT * FROM tb_recruit WHERE state = xxx ORDER BY createtime DESC LIMIT 0,6
     */
    public List<Recruit> findTop6ByStateOrderByCreatetimeDesc(String state);//

    /**
     * 查询最新职位列表,查询状态不为0并以创建日期降序排序
     * @param state
     * @return
     * SELECT * FROM tb_recruit WHERE state != xxx ORDER BY createtime DESC LIMIT 0,6
     */
    public List<Recruit> findTop6ByStateNotOrderByCreatetimeDesc(String state);//where state != xxx order by createtime Desc

}
原文地址:https://www.cnblogs.com/gdut-lss/p/11520185.html