This commit updates URLs to prefer the https protocol. Redirects are not followed to avoid accidentally expanding intentionally shortened URLs (i.e. if using a URL shortener). # Fixed URLs ## Fixed But Review Recommended These URLs were fixed, but the https status was not OK. However, the https status was the same as the http request or http redirected to an https URL, so they were migrated. Your review is recommended. * http://ethlo.com/maven (301) with 2 occurrences migrated to: https://ethlo.com/maven ([https](https://ethlo.com/maven) result 404). ## Fixed Success These URLs were switched to an https URL with a 2xx status. While the status was successful, your review is still recommended. * http://maven.apache.org/xsd/maven-4.0.0.xsd with 53 occurrences migrated to: https://maven.apache.org/xsd/maven-4.0.0.xsd ([https](https://maven.apache.org/xsd/maven-4.0.0.xsd) result 200). * http://maven.apache.org/maven-v4_0_0.xsd with 4 occurrences migrated to: https://maven.apache.org/maven-v4_0_0.xsd ([https](https://maven.apache.org/maven-v4_0_0.xsd) result 301). * http://projects.spring.io/spring-data-cassandra with 1 occurrences migrated to: https://projects.spring.io/spring-data-cassandra ([https](https://projects.spring.io/spring-data-cassandra) result 301). * http://projects.spring.io/spring-data-jpa with 1 occurrences migrated to: https://projects.spring.io/spring-data-jpa ([https](https://projects.spring.io/spring-data-jpa) result 301). * http://projects.spring.io/spring-data-ldap with 1 occurrences migrated to: https://projects.spring.io/spring-data-ldap ([https](https://projects.spring.io/spring-data-ldap) result 301). * http://projects.spring.io/spring-data-mongodb with 1 occurrences migrated to: https://projects.spring.io/spring-data-mongodb ([https](https://projects.spring.io/spring-data-mongodb) result 301). * http://projects.spring.io/spring-data-solr with 1 occurrences migrated to: https://projects.spring.io/spring-data-solr ([https](https://projects.spring.io/spring-data-solr) result 301). # Ignored These URLs were intentionally ignored. * http://maven.apache.org/POM/4.0.0 with 114 occurrences * http://www.w3.org/2001/XMLSchema-instance with 57 occurrences Original pull request: #454
Spring Data - Java 8 examples
This project contains samples of Java 8 specific features of Spring Data (JPA).
Support for JDK 8's Optional for repository methods
interface CustomerRepository extends Repository<Customer, Long> {
// CRUD method using Optional
Optional<Customer> findOne(Long id);
// Query method using Optional
Optional<Customer> findByLastname(String lastname);
}
CustomerRepository.findOne(Long)effectively "overrides" the defaultCrudRepository.findOne(…)to returnOptional.empty()instead ofnullin case no unique element satisfying the query can be found.CustomerRepository.findByLastname(…)does the same for a normal query method.
Support for JDK 8's date/time types in the auditing sub-system
CustomerextendsAbstractEntitywhich contains fields of JDK 8's new date/time API and those can be populated the same way legacy types likeDateandCalendarcan.
Support for JDK 8' Stream in repository methods
JPA repositories can now use Stream as return type for query methods to trigger streamed execution of the query. This will cause Spring Data JPA to use persistence provider specific API to traverse the query result one-by-one.
interface CustomerRepository extends Repository<Customer, Long> {
@Query("select c from Customer c")
Stream<Customer> streamAllCustomers();
}
try (Stream<Customer> customers = repository.streamAllCustomers()) {
// use the stream here
}
Note how the returned Stream has to be used in a try-with-resources clause as the underlying resources have to be closed once we finished iterating over the result.
Support for JDK 8' CompletableFuture in @Async repository methods
JPA repositories can now use CompletableFuture as return type for query methods for async execution of the query with support for fluent processing.
Note that: Support for CompletableFuture in combination with @Async is available in Spring Framework 4.2.x.
interface CustomerRepository extends Repository<Customer, Long> {
@Async
CompletableFuture<List<Customer>> readAllBy();
}
CompletableFuture<List<Customer>> future = repository.readAllBy().thenApply(this::doSomethingWithCustomers);
while (!future.isDone()) {
log.info("Waiting for the CompletableFuture to finish...");
TimeUnit.MILLISECONDS.sleep(500);
}
List<Customer> processedCustomers = future.get();