Java 如何将 OrderBy 与 GreaterThan Spring JPA 一起使用

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/35711184/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-11 17:02:42  来源:igfitidea点击:

How to use OrderBy with GreaterThan Spring JPA

javaspringjparepository

提问by Alberto Crespo

I want to add in my Repository interface a method which find all the data greater than a long publishdatavalue and Order it Decreacingly:

我想在我的 Repository 接口中添加一个方法,该方法可以查找大于某个long publishdata值的所有数据并按递减顺序对其进行排序:

I tried this, but it doesn't seems to be working:

我试过这个,但它似乎不起作用:

@Repository
public interface NoticiaRepository extends CrudRepository<Noticia,Long>{

    Noticia findById(long id);
    List<Noticia> findByOrderPublishdateGreaterThanDesc(long publishdate);

}

采纳答案by marok

List<Noticia> findByPublishdateGreaterThanOrderByPublishdateDesc(Long publishdate)