Reputation: 8397
I have very strange problem. In my repository, i need to extend JpaSpecificationExecutor<T>
interface to be able to use findAll(Specification<T>, Pageable)
for custom query paging.
But, when I use the JpaSpecificationExecutor,
public interface DescriptionRepository extends ParentRepositoryCustom<Description, Long>,
JpaSpecificationExecutor<Description> {
}
application won´t build, throwing No property count found for type class Description
exception.
My Description
class has no count attribute. When I remove JpaSpecificationExecutor
from repository, everything works well again.
Upvotes: 0
Views: 1388
Reputation: 1518
I came across the same exception. In my case, the reason was that the ParentRepositoryImpl was NOT exending correctly SimpleJpaRepository which is an implementation of JpaSpecificationExecutor. So when Spring try to resolve the query names, it exludes the method names belonging to what Spring call the repositoryBaseClass of your implementation. It s in the class org.springframework.data.repository.core.support.DefaultRepositoryInformation
public boolean isBaseClassMethod(Method method) {
return isTargetClassMethod(method, repositoryBaseClass);
}
Check that repositoryBaseClass is what you expect. It should defines the "count" method.
If you don't extends the correct superclass, the method ("count" in your case) is not excluded form resolution and Spring tries to build a query by creating it according to its name structure ... and in that case fragment of name are tested against your entity property.
Upvotes: 1