Implementing asynchronous Spring Data JPA properties
Previously, we had lots of recipes and snippets regarding how to build repositories using the Spring Data JPA module through Spring Boot 2.0. All the repository properties created earlier were mostly non-blocking that return typical collections of model data. This recipe will focus on asynchronous JpaRepository
properties that retrieve Future<T>
, CompletableFuture<T>
, and ListenableFuture<T>
.
Getting ready
Create a new Maven project, ch12-asyncjpa
, that will implement the Spring Data JPA with asynchronous properties.
How to do it...
Let us now explore the asynchronous side of Spring Data JPA module:
- Convert
ch12-asyncjpa
to a Spring Boot 2.0 application by adding the Spring Boot 2.0.0.M2starter POM dependencies, such aswebflux
,actuator
for project status monitoring and management, Spring JDBC, and MYSQL connector. - Since there is no dedicated Spring Data JPA module for asynchronous repository transactions, add the same starter...