我有一个包含uid字段的抽象域类,如下所示:
public abstract class GraphEntityWithUid extends GraphEntity {
private String uid = CommonUtils.newUid();
public String getUid() {
return uid;
}
public void setUid(String uid) {
this.uid = uid;
}
}
并且,它的抽象存储库:
public abstract interface GraphEntityWithUidRepository<T extends GraphEntityWithUid> extends GraphRepository<T> {
public T findByUid(String uid);
}
我有一个继承uid的具体域类,如下所示:
@NodeEntity
public class Attachment extends GraphEntityWithUid {
...
}
而且,它的存储库如下所示:
public interface AttachmentRepository extends GraphEntityWithUidRepository<Attachment> {
}
现在,当我使用findByUid
方法时,如下所示:
// returns null
attachmentRepository.findByUid(uid);
它总是返回null。但是,如果我在AttachmentRepository
中重新声明方法如下,它可以正常工作:
public interface AttachmentRepository extends GraphEntityWithUidRepository<Attachment> {
// Shouldn't this be automatically inherited??
public Attachment findByUid(String uid);
}
为什么我需要在findByUid
中重新声明AttachmentRepository
方法?不应该自动从GraphEntityWithUidRepository
继承?