我有办法
List<Notification> findTop20ByToUserIdAndIdGreaterThanAndOrderByIdDesc(Long ToUserId, Long lastId);我有通知列表,使用此方法我想:
的通知
对20进行排序
这不起作用,并抛出异常:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'notificationRepo': FactoryBean threw exception on object creation; nested exception is java.lang.IllegalArgumentException: Failed to create query for method public abstract java.util.List com.bagenger.persistence.dao.NotificationRepo.findTop20ByToUserIdAndIdGreaterThanAndOrderByIdDesc(java.lang.Long)! No property greaterThanAnd found for type Long! Traversed path: Notification.id. My Entity:
@Entity
@Data
public class Notification {
@Id
@GeneratedValue(strategy= GenerationType.AUTO)
@Column(name = "id", unique = true, nullable = false)
private Long id;
private Long fromUserId;
private Long toUserId;
private String url;
@ColumnDefault("false")
private boolean isRead;
private String message;
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm")
private LocalDateTime createDate;
}我怎样才能重写适当的工作方法呢?
发布于 2020-08-30 00:35:12
看起来问题就像在方法名称中应该添加实体类名:通知--这个方法是工作的:
List<Notification> findTop20NotificationByToUserIdAndIdGreaterThanOrderByIdDesc(Long ToUserId, Long lastId);发布于 2020-08-30 04:22:55
方法名称不符合标准。您可以尝试使用下面的方法名。
List<Notification> findTop20NoByToUserIdIsAndIdIsGreaterThanOrderByIdDesc(Long ToUserId, Long lastId);https://stackoverflow.com/questions/63649499
复制相似问题