Loading...

Latest Posts

Spring September 13, 2023

Spring Events: Decouple Your Application with @EventListener and ApplicationEvents

If you’re already working with the Spring Framework, you’ve undoubtedly recognized its power and versatility. One of the valuable - yet often overlooked - features of Spring is its event-handling system. In this article, we’ll delve deeper into how you can configure events in the Spring Framework using @EventListener. Moreover, we’ll illustrate how these events can be paired with transactions and asynchronicity. Why Events in the Spring Framework? Events are an integral component of the Spring Framework.


Spring September 6, 2023

Spring's Assert Class: The Smart Way to Validate

There are many ways to ensure your code does what it’s supposed to do. Java even has a built-in assert language feature for this very purpose. And then there’s Spring’s Assert class. But why should I use this? In this article, we delve deeply into the subject and explore the advantages of using this class for validating your data and arguments. Why Use Assertions at All? Before diving into the details of the Spring Assert class, let’s briefly clarify the significance of assertions.


Spring August 30, 2023

Open Session in View (OSIV) in Spring - Enable or Disable?

If you are working with Spring Boot and Hibernate, you have undoubtedly come across the term “Open Session in View” (OSIV) or its corresponding property open-in-view. But what exactly does this option do, and how does it affect your interaction with the database? Should you enable or disable it? In this article, we delve deep into the topic and shed light on its functionality and differences compared to other approaches.


Spring August 23, 2023

Spring MVC: How to Use a Custom Converter for Type Safety in Controllers

Are your controllers constantly filled with primitives? In ArticleController, the first line of every method is: articleRepository.findById(articleId). We keep making the same conversions. I hardly observe as many primitives in any other layer as in the API layer. This leads to much boilerplate. The code becomes harder to test. And it’s harder to read. Yet we know how much easier it is when we work with type safety. In this article, I will show you how to use the Converter Interface to automatically convert your primitives into the correct type.


Spring August 16, 2023

Avoiding Static Access to SecurityContext with @AuthenticationPrincipal in Spring

In almost every web application, logic related to the user must be executed. To access this, his data is assigned based on his authentication. With Spring Security, the authentication framework in the Spring stack, we have various ways to accomplish this essential task. Static Access and its Drawbacks In many applications and examples, it is common to statically retrieve the SecurityContext in Spring to access the current UserDetails. However, this has some disadvantages:


Top