Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/jpa/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Hibernate Spring数据JPA方法_Hibernate_Jpa_Methods_Spring Data Jpa_Spring Data - Fatal编程技术网

Hibernate Spring数据JPA方法

Hibernate Spring数据JPA方法,hibernate,jpa,methods,spring-data-jpa,spring-data,Hibernate,Jpa,Methods,Spring Data Jpa,Spring Data,我有办法 List<Notification> findTop20ByToUserIdAndIdGreaterThanAndOrderByIdDesc(Long ToUserId, Long lastId); 我怎样才能重写方法以使其正常工作?问题似乎出在方法的名称中,应该添加实体类名:Notification 这一个正在工作: List<Notification> findTop20NotificationByToUserIdAndIdGreaterThanOrder

我有办法

List<Notification> findTop20ByToUserIdAndIdGreaterThanAndOrderByIdDesc(Long ToUserId, Long lastId);

我怎样才能重写方法以使其正常工作?

问题似乎出在方法的名称中,应该添加实体类名:Notification 这一个正在工作:

List<Notification> findTop20NotificationByToUserIdAndIdGreaterThanOrderByIdDesc(Long ToUserId, Long lastId);
列出FindTop20 NotificationByToUserId和IDgreater,而不是OrderByIDdesc(长ToUserId,长lastId);

方法名称不符合标准。您可以尝试下面的方法名

List<Notification> findTop20NoByToUserIdIsAndIdIsGreaterThanOrderByIdDesc(Long ToUserId, Long lastId);
List findtop20nobytouserid和idisgreaterthanorderbyiddesc(Long-toserid,Long-lastId);

嵌套异常表示:greaterthand不是运算符。您在greaterthan和orderby之间进行逻辑and,这是错误的。删除“和”,此版本也不起作用:1。通过以下方式找到OP20,并且比IDORDERBYIDESC 2更大。通过ToUserIdDescandCreateThan查找Top20
List<Notification> findTop20NotificationByToUserIdAndIdGreaterThanOrderByIdDesc(Long ToUserId, Long lastId);
List<Notification> findTop20NoByToUserIdIsAndIdIsGreaterThanOrderByIdDesc(Long ToUserId, Long lastId);