Category: Spring
How to Grouping and restricting constraints using Bean Validation?
Natan Ferreira- 0
- 406
We already know that the Bean Validation specification is very helpful for performing validations. There is also the possibility of validating using groups. Imagine the following scenario: a DTO for products and another one for categories, as in the following example: When trying to register a product by specifying the category id, we encounter an…
Read More
What is Java Bean Validation and how to use it?
Natan Ferreira- 0
- 626
Bean Validation is a specification for performing validations in Java and can have multiple implementations. To avoid writing repetitive validation code, Java provides Bean Validation (standard specified by JSR 380, also known as Jakarta Bean Validation), which allows applying rules directly to class attributes using annotations. When developing Java applications, it is common to validate…
Read More
How to Manage Profiles in Spring Boot (with Docker)?
Natan Ferreira- 0
- 977
Spring Boot allows you to use profiles to separate configurations by environment, such as development (dev), staging (staging), and production (prod). This makes it easier to manage settings like database URLs, feature flags, and other environment-specific behaviors. In this post, you’ll learn how to: 📁 File Structure 🔧 Configuration Files 🔧 application.properties (common) 🔧 application-dev.properties…
Read More
How to use Domain Events in Spring?
Natan Ferreira- 0
- 329
In the world of Domain-Driven Design (DDD), Domain Events are a powerful way to notify different parts of a system that something meaningful has occurred within the core domain. Within the Spring ecosystem, event support is simple yet highly effective for decoupling components, improving cohesion, and enabling systems to evolve gracefully. In this post, you’ll…
Read More
What are Checked vs Unchecked Exceptions in Java?
Natan Ferreira- 0
- 802
In Java, exceptions are part of the Throwable hierarchy and are used to signal abnormal situations during the execution of a program. Understanding how exceptions are structured helps in designing more robust and readable code. At the top of the hierarchy is the Throwable class, which has two direct subclasses: Checked Exceptions Checked exceptions are…
Read More
How to paginate using Spring Data JPA?
Natan Ferreira- 0
- 964
Spring Data JPA enables pagination through the JpaRepository interface, which extends PagingAndSortingRepository — an interface that provides pagination support. Let’s go over more details with a practical example. If you need to understand how Spring Data JPA works, there are more articles on the blog explaining that: Hands on You’ll need some of the following…
Read More
What’s the difference between Concurrency and Parallelism?
Natan Ferreira- 0
- 306
Concurrency and Parallelism are important concepts for bringing more efficiency to software, but they do not mean the same thing. A software application can handle multiple tasks, and the way these tasks are processed differs in each concept. Concurrency Imagine the scenario where we have a software that needs to process multiple tasks, such as…
Read More
How to create a custom repository in Spring Data JPA?
Natan Ferreira- 0
- 1030
Spring Data JPA is great for abstracting away boilerplate code when accessing the database. It allows us to create query methods by simply defining method signatures. But sometimes, we need more complex or dynamic queries — and that’s where custom repositories come into play. In this post, I’ll show how to create a custom repository…
Read More
What is Spring Data JPA?
Natan Ferreira- 0
- 697
Spring Data JPA is a module of Spring Data that simplifies the implementation of repositories. It provides an automatic way to create repository implementations based on Java interfaces, eliminating the need to manually write the repository implementation. To make this work, you need to create an interface using the @Repository annotation and extend JpaRepository. The…
Read More
How to avoid NullPointerException in Java using Optional?
Natan Ferreira- 0
- 624
Optional was introduced in Java 8 as a way to handle potentially null values more safely and expressively. It helps to avoid NullPointerException and makes the code more readable. Hands on Creating an Optional Optional can be created in several ways: Printing the results will show the following output. Checking for Value Presence Optional provides…
Read More