0
I’ve been line by line to find out what’s different between an object that’s worked and what’s going wrong and I can’t find the problem. This Student object is giving error. If I comment the get goes up 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);
}
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));
}
Try renaming
StudentRepositoryImpl
forStudentRepositoryQueryImpl
. If it works, let me know and I’ll create an appropriate response.– StatelessDev
@Statelessdev The error still continues. The others that work are also missing from the query.
– Cleriston Lincoln