Search code examples
spring-bootspring-data-jpaspring-data

No property 'findAll' found for type 'Department'


I am facing an issue after migrating from spring-boot 1.5.3-release to 2.7.16, the error is DepartmentRepository.findAll(java.lang.Iterable)! No property 'findAll' found for type 'Department'

import java.util.List;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
import com.auth.middleware.domain.Department;

@Repository

public interface DepartmentRepository extends CrudRepository<Department, Long> {

@Transactional(timeout = 8)
List<Department> findAll();
 

/**
 * 
 * @param deptId
 * @return
 */
Department findByDeptId(Long deptId);

/**
 * @param deptName
 * @return
 */
Department findByDeptName(String deptName);

/**
 * 
 * @param deptId
 */
void deleteByDeptId(Long deptId);


/**
 * @param deptIds
 */
@Transactional(timeout = 8)
Iterable<Department> findAll(Iterable<Long> deptIds);



}

The error is coming while starting the application Invocation of init method failed; nested exception is org.springframework.data.repository.query.QueryCreationException: Could not create query for public abstract java.lang.Iterable com.auth.middleware.repository.DepartmentRepository.findAll(java.lang.Iterable); It was working before in spring-boot 1.5.3-release, after upgrading to 2.7.16 I am facing this issue.


Solution

    • Is it possible to edit the DepartmentRepository class?
    • Also, using findAll( Iterable ), are you trying to get rows for the passed department ids?

    If answers to both is "yes", then please try renaming the method to findByDeptIdIn( Iterable ). (Since the Department class is not available here, please ensure that you use the right field property name and path, including the key property's name, if applicable).