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);