Category: Spring

What’s the difference between Concurrency and Parallelism?
Natan Ferreira
- 0
- 44
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
- 115
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
- 128
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
- 134
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
How do @PostConstruct and @PreDestroy annotation work in java?
Natan Ferreira
- 0
- 163
Methods annotated with @PostConstruct and @PreDestroy are commonly used in the lifecycle of beans managed by the container, such as in frameworks like Spring or Quarkus. An example of their use is opening and closing database connections. If you want to know more about Bean management in Spring, don’t hesitate to read this post. @PostConstruct…
Read More
How do functional interfaces work in Java?
Natan Ferreira
- 0
- 205
Functional Interfaces are a fundamental concept in functional programming introduced in Java 8. They are interfaces that have exactly one abstract method, allowing the use of lambda expressions and method references to make the code more concise and readable. They can be used in Streams, for example, and promote code reuse. We can find several…
Read More
What is Shallow Copy and Deep Copy in Java?
Natan Ferreira
- 0
- 187
When developing software, there may be situations where it is necessary to create copies of objects to prevent unwanted behaviors, whether to avoid different parts of the system modifying the same object or for any other reason that prevents undesired behavior. Java provides the Cloneable interface, which allows object copying. There are two types of…
Read More
How does serialization and deserialization work in Java?
Natan Ferreira
- 0
- 219
Serialization and deserialization are essential for persisting or transferring data between systems. Serialization transforms Java objects into formats like JSON or XML, enabling storage or network transmission. Deserialization, on the other hand, restores these objects, making the data reusable in applications. These processes are widely used in APIs, data persistence, and communication between distributed systems,…
Read More
How to use Generic Types in Java?
Natan Ferreira
- 0
- 121
The use of Generics in Java improves security, readability, and code reuse, simplifying the development of robust and secure applications. Let’s see some usage examples below. Generic Methods <T>: It’s a generic type parameter, accepting any type. T Item: The method accepts a parameter of the generic type. We can specify, for example, String and…
Read More
How to sort Java Collections?
Natan Ferreira
- 0
- 139
Sorting in Java Collections is an essential feature for organizing collection elements in ascending or descending order. Using the Comparable or Comparator interfaces, custom sorting criteria can be defined. The Collections class provides utility methods, such as sort(), to apply these rules. This enables efficient and flexible data processing. Hands on The following example is…
Read More