I've been line by line to know what's different between an object that worked and what's going wrong and I can not find the problem. This Student object is giving error. If I comment on get sobe normal.
Code error:
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'studentResource': Unsatisfied dependency expressed through field 'repository'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'studentRepository': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Failed to create query for method public abstract org.springframework.data.domain.Page com.school.repository.query.StudentRepositoryQuery.filtrar(com.school.repository.filter.StudentFilter,org.springframework.data.domain.Pageable)! No property filtrar found for type Student!
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'studentRepository': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Failed to create query for method public abstract org.springframework.data.domain.Page com.school.repository.query.StudentRepositoryQuery.filtrar(com.school.repository.filter.StudentFilter,org.springframework.data.domain.Pageable)! No property filtrar found for type Student!
Caused by: org.springframework.data.mapping.PropertyReferenceException: No property filtrar found for type Student!
Resource class:
public class StudentResource {
@GetMapping
public Page<Student> getFiltreEntity(StudentFilter studentFilter, Pageable pageable) {
return repository.filtrar(studentFilter, pageable);
}
Repository Class
public interface StudentRepository extends JpaRepository<Student, Long>, StudentRepositoryQuery{}
Query Class
public interface StudentRepositoryQuery {
Page<Student> filtrar(StudentFilter studentFilter, Pageable pageable);
}
Impl Class
public class StudentRepositoryImpl implements StudentRepositoryQuery{
@Override
public Page<Student> filtrar(StudentFilter studentFilter, Pageable pageable) {
CriteriaBuilder builder = manager.getCriteriaBuilder();
CriteriaQuery<Student> criteria = builder.createQuery(Student.class);
Root<Student> root = criteria.from(Student.class);
Predicate[] predicates = createFilter(studentFilter, builder, root);
criteria.where(predicates);
TypedQuery<Student> query = manager.createQuery(criteria);
addPageRestrict(query, pageable);
return new PageImpl<>(query.getResultList(), pageable, total(studentFilter));
}