I have the following repository:
PermissionRepository:
public interface PermissionRepository extends CrudRepository<Permission, Long>,
SearchRepository<Permission> {
}
In my service, I am trying to map Permission entity to PermissionDTO, but as findAll() method returns Iterable<T> (Iterable<T> findAll();), I cannot convert as shown below as I generally use for List<T>. It throws "Cannot resolve method 'stream' in 'Iterable'" error for the .stream() method.
List<PermissionDTO> list = permissionRepository.findAll()
.stream()
.map(PermissionDTO::new)
.collect(Collectors.toList());
So, how can I map this Permission entity to PermissionDTO?