#66 - Added JPA example for using Java 8 Streams with a derived query.
This example demonstrates the usage of Java 8 Stream as return type for derived queries.
This commit is contained in:
committed by
Oliver Gierke
parent
2569cf8de3
commit
65cef4132d
@@ -26,6 +26,7 @@ import org.springframework.data.repository.Repository;
|
||||
* Repository to manage {@link Customer} instances.
|
||||
*
|
||||
* @author Oliver Gierke
|
||||
* @author Thomas Darimont
|
||||
*/
|
||||
public interface CustomerRepository extends Repository<Customer, Long> {
|
||||
|
||||
@@ -64,11 +65,19 @@ public interface CustomerRepository extends Repository<Customer, Long> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Sample method to demonstrate support for {@link Stream} as a return type. The query is executed in a streaming
|
||||
* fashion which means that the method returns as soon as the first results are ready.
|
||||
* Sample method to demonstrate support for {@link Stream} as a return type with a custom query. The query is executed
|
||||
* in a streaming fashion which means that the method returns as soon as the first results are ready.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Query("select c from Customer c")
|
||||
Stream<Customer> streamAllCustomers();
|
||||
|
||||
/**
|
||||
* Sample method to demonstrate support for {@link Stream} as a return type with a derived query. The query is
|
||||
* executed in a streaming fashion which means that the method returns as soon as the first results are ready.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
Stream<Customer> findAllByLastnameIsNotNull();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user