Já fui linha a linha pra saber o que tem de diferente entre um objeto que deu certo e o que está dando errado e não consigo achar o problema. Este objeto Student está dando erro. Se eu comentar o get sobe normal.
Erro do codigo:
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!
Classe Resource:
public class StudentResource {
@GetMapping
public Page<Student> getFiltreEntity(StudentFilter studentFilter, Pageable pageable) {
return repository.filtrar(studentFilter, pageable);
}
Classe Repository
public interface StudentRepository extends JpaRepository<Student, Long>, StudentRepositoryQuery{}
Classe Query
public interface StudentRepositoryQuery {
Page<Student> filtrar(StudentFilter studentFilter, Pageable pageable);
}
Classe Impl
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));
}
StudentRepositoryImpl
paraStudentRepositoryQueryImpl
. Se funcionar, avise que eu crio uma resposta apropriada. – StatelessDev 27/09/18 às 0:51