I'm using spring data and have a repository that extends JpaRepository and QueryDslPredicateExecutor. I get a list of entities from the repository by calling the Iterable findAll(Predicate p) method. I was wondering, is it possible to get a Stream returned from the repository passing in a querydsl predicate as an argument?
as described in https://github.com/spring-projects/spring-data-commons/issues/1169#issuecomment-752400977, you can declare your own method that returns List<...>
import java.util.List;
import org.bson.types.ObjectId;
import org.springframework.data.mongodb.repository.MongoRepository;
import org.springframework.data.querydsl.QuerydslPredicateExecutor;
import org.springframework.stereotype.Repository;
import com.querydsl.core.types.Predicate;
@Repository
public interface MyEntityRepository extends MongoRepository<MyEntity, ObjectId>, QuerydslPredicateExecutor<MyEntity> {
List<MyEntity> findAll(Predicate predicate);
}
then simply
myEntityRepository.findAll(myPredicate).stream()....