早上好!
我的Spring应用程序似乎没有检测到existsBy投影
Caused by: org.springframework.data.mapping.PropertyReferenceException: No property existsById found for type Planet!
at org.springframework.data.mapping.PropertyPath.<init>(PropertyPath.java:77)
at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:329)
at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:309)
at org.springframework.data.mapping.PropertyPath.from(PropertyPath.java:272)
存储库中的代码
public boolean existsByIdAndOwnerId(Long planetId, Integer ownerId);
提前致谢!
答案 0 :(得分:1)
尝试命名方法:existsPlanetByIdAndOwnerId()
此链接可能有助于: https://www.baeldung.com/spring-data-derived-queries
答案 1 :(得分:0)
如果要在存储库中扩展CrudRepository<T, ID>
,它会提供existById(ID)
,它将id作为参数,并根据db条目的存在返回Boolean。对于您的情况,您可以这样做:public boolean findByIdAndOwnerId(Long planetId, Integer ownerId);