In Event-driven architecture there are unique identifiers everywhere: at entity level, at event level, at process level etc.
In this blog post, I will show you a de facto standard for how you could easily generate, persist, serialize and deserialize IDs natively through Kafka, Java and JPA.
Testing pessimistic locking handling in JPA is tricky because of the lack of JPA support of LockTimeout by different RDBMS providers.
Yet leaving a critical part of the code untested is against the software craftsmanship's principles.
In this blog post, I will show you through the medium of 3 GitHub projects how you could test it within Spring Boot Application against Oracle, MySQL and PostgreSQL.
One of the key properties for correct pessimistic locking handling and testing is LockTimeout.
Unfortunately its JPA support by different RDBMS providers is far from complete.
In this article I will show you how you may overcome this limitation on Oracle, MySQL, PostgreSQL, Apache Derby and H2.
Moreover, I will give you some suggestions about when pessimistic locking might be the correct solution and when not.
While optimistic locking handling in JPA is relatively well-known, it is usually poorly tested or not tested at all.
In this blog post I will show you firstly what does optimistic locking handling mean and how you could implement it within a Spring Boot Application and JPA.
After that you could see a way to write integration tests, which I hope could surprise you with their simplicity and efficiency!