One of the main reasons I blog is to remind myself how easily one can use software development techniques to make bad decisions. I do it myself all the time… In a recent project, I was working with Spring Data which is able to create powerful CRUD operations over data sources if you just create an interface: interface FooRepository extends ...
Read More »Home »
Spring Boot Data JPA – beginner guide
Databases form an integral part of computer applications. With it comes considerable amount of database operations and the corresponding code. For huge applications which have large number of tables/entities, these operations or the code is repeated and duplicated to a large extent. Eventually a programmer would like to reduce this duplicate code. Spring framework took up the challenge and provided ...
Read More »Read replicas and Spring Data Part 4: Configuring the read repository
Previously we set up two EntityManagers in the same application. One for the reads and one for the writes. Now it’s time to create our read repository. The read only repository will use the secondary read only EntityManager. In order to make it a read only repository, it is essential not to have any save and persist actions. 01 02 ...
Read More »Read replicas and Spring Data Part 3: Configuring two entity managers
Our previous setup works as expected. What we shall do now is to get one step further and configure two separate entity managers without affecting the functionality we achieved previously. The first step would be to set the default entity manager configuration to a primary one.This is the first step 01 02 03 04 05 06 07 08 09 10 ...
Read More »Read replicas and Spring Data Part 2: Configuring the base project
In our previous post we set up multiple PostgreSQL instances with the same data.Our next step would be to configure our spring project by using the both servers. As stated previously we shall use some of the code taken from the Spring Boot JPA post, since we use exactly the same database. This shall be our gradle build file 01 ...
Read More »Read replicas and Spring Data Part 1: Configuring the Databases
This is a series of blog posts on our quest to increase our application’s performance by utilizing read replicas. For this project our goal is to set up our spring data application and use read repositories for writes and repositories based on read replicas for reads. In order to simulate this environment we shall use PostgreSQL instances through Docker. The ...
Read More »Augmenting a Spring Data repository through delegation
I have recently written several posts about Kotlin’s delegation. In doing so, I realised a useful way to apply it to Spring Data repositories. Which would allow Spring Data to continue sprinkling some magic while providing a route for customisation. The code shown in this post is in Kotlin, but is still relevant to Java. This post uses R2DBC, but ...
Read More »Streaming live updates from a reactive Spring Data repository
This post details a naive implementation of streaming updates from a database to any other components that are interested in that data. More precisely, how to alter a Spring Data R2DBC repository to emit events to relevant subscribers. A little bit of background knowledge of R2DBC and Spring will be helpful for this post. My previous writings, Asynchronous RDBMS access ...
Read More »Asynchronous RDBMS access with Spring Data R2DBC
Not too long ago, a reactive variant of the JDBC driver was released. Known as R2DBC. It allows data to be streamed asynchronously to any endpoints that have subscribed to it. Using a reactive driver like R2DBC together with Spring WebFlux allows you to write a full application that handles receiving and sending of data asynchronously. In this post, we ...
Read More »