我已经在Spring Data JpaRespository上添加了一个带有单个自定义方法的自定义接口,详见该问题的答案;
How to add custom method to Spring Data JPA
但是现在我收到以下错误;
Caused by: org.springframework.data.mapping.PropertyReferenceException: No property customMethod found for type Account!
at org.springframework.data.mapping.PropertyPath.<init>(PropertyPath.java:75)
at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:327)
at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:307)
at org.springframework.data.mapping.PropertyPath.from(PropertyPath.java:270)
at org.springframework.data.mapping.PropertyPath.from(PropertyPath.java:241)
at org.springframework.data.repository.query.parser.Part.<init>(Part.java:76)
这似乎是因为Spring Data试图为“customMethod”生成一个查询,认为它是“帐户”的属性。
如何停止给定方法的自动查询生成?!
UPDATE 我的代码具体如下;
public interface CacheInvalidatingRepo<T> {
public void invalidateCache(T obj);
}
@Component
public class CacheInvalidatingRepoImpl<T> implements CacheInvalidatingRepo<T> {
@Override
public void invalidateCache(T obj) {
// kill the entity manager cache
}
}
public interface VerificationRepo extends JpaRepository<Verification, BigInteger>, JpaSpecificationExecutor<Verification>, CacheInvalidatingRepo<Verification> {
}
以下结果;
Caused by: org.springframework.data.mapping.PropertyReferenceException: No property invalidateCachefound for type Verification!
at org.springframework.data.mapping.PropertyPath.<init>(PropertyPath.java:75)
at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:327)
at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:307)
at org.springframework.data.mapping.PropertyPath.from(PropertyPath.java:270)
at org.springframework.data.mapping.PropertyPath.from(PropertyPath.java:241)
at org.springframework.data.repository.query.parser.Part.<init>(Part.java:76)