eBook – Guide Spring Cloud – NPI EA (cat=Spring Cloud)
announcement - icon

Let's get started with a Microservice Architecture with Spring Cloud:

>> Join Pro and download the eBook

eBook – Mockito – NPI EA (tag = Mockito)
announcement - icon

Mocking is an essential part of unit testing, and the Mockito library makes it easy to write clean and intuitive unit tests for your Java code.

Get started with mocking and improve your application tests using our Mockito guide:

Download the eBook

eBook – Java Concurrency – NPI EA (cat=Java Concurrency)
announcement - icon

Handling concurrency in an application can be a tricky process with many potential pitfalls. A solid grasp of the fundamentals will go a long way to help minimize these issues.

Get started with understanding multi-threaded applications with our Java Concurrency guide:

>> Download the eBook

eBook – Reactive – NPI EA (cat=Reactive)
announcement - icon

Spring 5 added support for reactive programming with the Spring WebFlux module, which has been improved upon ever since. Get started with the Reactor project basics and reactive programming in Spring Boot:

>> Join Pro and download the eBook

eBook – Java Streams – NPI EA (cat=Java Streams)
announcement - icon

Since its introduction in Java 8, the Stream API has become a staple of Java development. The basic operations like iterating, filtering, mapping sequences of elements are deceptively simple to use.

But these can also be overused and fall into some common pitfalls.

To get a better understanding on how Streams work and how to combine them with other language features, check out our guide to Java Streams:

>> Join Pro and download the eBook

eBook – Jackson – NPI EA (cat=Jackson)
announcement - icon

Do JSON right with Jackson

Download the E-book

eBook – HTTP Client – NPI EA (cat=Http Client-Side)
announcement - icon

Get the most out of the Apache HTTP Client

Download the E-book

eBook – Maven – NPI EA (cat = Maven)
announcement - icon

Get Started with Apache Maven:

Download the E-book

eBook – Persistence – NPI EA (cat=Persistence)
announcement - icon

Working on getting your persistence layer right with Spring?

Explore the eBook

eBook – RwS – NPI EA (cat=Spring MVC)
announcement - icon

Building a REST API with Spring?

Download the E-book

Course – LS – NPI EA (cat=Jackson)
announcement - icon

Get started with Spring and Spring Boot, through the Learn Spring course:

>> LEARN SPRING
Course – RWSB – NPI EA (cat=REST)
announcement - icon

Explore Spring Boot 3 and Spring 6 in-depth through building a full REST API with the framework:

>> The New “REST With Spring Boot”

Course – LSS – NPI EA (cat=Spring Security)
announcement - icon

Yes, Spring Security can be complex, from the more advanced functionality within the Core to the deep OAuth support in the framework.

I built the security material as two full courses - Core and OAuth, to get practical with these more complex scenarios. We explore when and how to use each feature and code through it on the backing project.

You can explore the course here:

>> Learn Spring Security

Course – LSD – NPI EA (tag=Spring Data JPA)
announcement - icon

Spring Data JPA is a great way to handle the complexity of JPA with the powerful simplicity of Spring Boot.

Get started with Spring Data JPA through the guided reference course:

>> CHECK OUT THE COURSE

Partner – Moderne – NPI EA (cat=Spring Boot)
announcement - icon

Refactor Java code safely — and automatically — with OpenRewrite.

Refactoring big codebases by hand is slow, risky, and easy to put off. That’s where OpenRewrite comes in. The open-source framework for large-scale, automated code transformations helps teams modernize safely and consistently.

Each month, the creators and maintainers of OpenRewrite at Moderne run live, hands-on training sessions — one for newcomers and one for experienced users. You’ll see how recipes work, how to apply them across projects, and how to modernize code with confidence.

Join the next session, bring your questions, and learn how to automate the kind of work that usually eats your sprint time.

Course – LJB – NPI EA (cat = Core Java)
announcement - icon

Code your way through and build up a solid, practical foundation of Java:

>> Learn Java Basics

1. Overview

JPA Buddy is a widely used IntelliJ IDEA plugin targeted to both new and experienced developers who work with JPA data model and related technologies like Spring Data JPA, DB versioning tools (Flyway, Liquibase), MapStruct, and some others. The plugin provides visual designers, code generation, and additional inspections that should simplify the development and improve the code according to the best practices for JPA.

The plugin works under both Community and Ultimate versions of IntelliJ IDEA and uses the “freemium” model. Most features are available for free, and we’ll need to buy a subscription to access the paid ones.

In this tutorial, we’ll look at the plugin’s main features and see how we can use them during the application development cycle. As an example, we’re going to use the popular reference application – “Spring PetClinic“.

2. Getting Started

We can activate JPA Buddy automatically when adding a JPA dependency to the application source code. The plugin is in the “Recommended InteiilJ Plugins” list, so even if we don’t have it installed, IDEA will suggest we do this. We can also install the plugin from IntelliJ’s marketplace:

JpaBuddy Notification Window

JPA Buddy functionality may vary depending on the libraries attached to the application. E.g., we won’t see menus for DB versioning scripts generation if we have neither Liquibase nor Flyway attached.

3. Working with JPA Entities

Usually, application development starts with the data model. JPA Buddy provides a visual designer and component palette that allows us to create an entity and add basic attributes and associations to it. We can invoke the corresponding action from a context menu or the JPA Structure tool window:

Screenshot-2022-11-15-at-12.08.36

 

If we need to add or edit an entity attribute, we can use the JPA palette and inspector. To add an attribute, we need to double-click on it or perform drag-and-drop. The visual editor allows us to define the attribute properties:

Attribute visual editor

To edit an entity’s attribute, we can use the JPA inspector. According to JPA specs, the inspector allows us to view and edit almost all options for an entity’s attribute. The editor works both ways: when we update an attribute’s property, the code is updated. And vice versa, when the entity’s code is updated, all changes are reflected in the inspector.

3.1. Lombok Support

According to JPA Specs, entities should have getters and setters for attributes, and this is often treated as “boilerplate” code. Lombok is a popular library that allows us to avoid writing boilerplate and replace it with a couple of annotations. Many developers use Lombok in the JPA entities definition, so JPA Buddy supports it fully. We can edit Lombok-related properties in the JPA Inspector:

Lombok support in inspector

The plugin functionality is not limited to inspection and editing. The important part of the support is inspections. Some Lombok annotations might cause performance issues or unexpected errors when used with JPA. For example, using @ToString annotation might cause LazyInitException because it uses all attributes for an object string representation, including lazy ones.

JPA Buddy shows warnings for such cases and provides quick fixes, and it helps us to avoid bugs in the JPA code:

Lombok code inspection warning

4. DB Migration with Liquibase and Flyway

To create a database from the JPA data model, we usually use DB versioning tools; Liquibase and Flyway are two big players in this area. The most error-prone part of the DB migration process is writing the migration script based on the JPA entity’s changes. JPA Buddy provides schema differential script generation for both Liquibase and Flyway. The plugin can compare the existing DB schema to the JPA model or even two schemas:

Migration scripts preview window

In addition to this, JPA Buddy provides scripts autocompletion and smart preview. In this mode, the plugin analyzes the generated scripts and shows a warning if changes can cause failures in the target data source on update:

Warning for a potentially dangerous code

5. Spring Data JPA Support

When the data model is created, the next step is the implementation of the data access repositories. Spring Data JPA is probably the most popular framework for this. JPA Buddy allows us to generate new repositories based on entity definitions. In the repository code, we can use the JPA palette to create various derived methods and queries in a repository code using visual tools. JPA Buddy can generate code to return DTOs and Spring Data Projections from a repository method.

Screenshot-2022-11-15-at-13.27.17

 

 

One more useful feature is query extraction. Sometimes derived method names might become too long for complex queries like this:

List<Owner> findDistinctByFirstNameIgnoreCaseOrLastNameIgnoreCaseOrPets_NameIgnoreCaseAllIgnoreCaseOrderByFirstNameAsc(
  String firstName, String lastName, String name);

JPA Buddy analyzes a derived method name and allows us to refactor it by renaming and moving the JPQL query to @Query annotation:

JPA Repository query extraction window
@Query("select distinct o from Owner o left join o.pets pets " +
  "where upper(o.firstName) = upper(:firstName) " +
  "or upper(o.lastName) = upper(:lastName) " +
  "or upper(pets.name) = upper(:name) " +
  "order by o.firstName")
List<Owner> findByAnyName(@Param("firstName") String firstName,
  @Param("lastName") String lastName,
  @Param("name") String name);

6. Entities Generation Based on DB Tables

Data usually outlives the code, so when we build a JPA Data layer over an existing database, we need to create JPA entities based on the current tables. JPA Buddy provides this functionality and allows developers to create entities by selecting desired tables. In contrast to the existing solutions, the plugin performs “smart” generation and tries to detect associations between entities. We will generate the corresponding attributes even for OneToMany and ManyToMany entities that are not backed with columns:

Screenshot-2022-11-15-at-12.46.02

7. DTOs and Mappers Generation

DTO is a valuable design pattern for the case of passing data that we cannot map directly to JPA entities. For example, when creating REST API, we might want to expose only some entity attributes.

JPA Buddy can generate DTOs and mappers with the MapStruct library. All we need to do is to select desired attributes for generated DTOs:

DTO Generation window

The plugin generates a DTO and a mapper, including proper mapping for the associations. JPA Buddy supports Lombok for this case too and generates proper annotations for DTOs:

@Data
public class OwnerDto implements Serializable {
   private final Integer id;
   @NotEmpty
   private final String firstName;
   @NotEmpty
   private final String lastName;
   private final List<PetDto> pets;
}

JPA Buddy also can generate entities from POJOs. It may be useful if you develop your application starting from API definition, not from data model.

Screenshot-2022-11-15-at-14.19.38

8. Minimalistic Mode

JPA Buddy has a friendly UI, but for those who prefer a “focused” view in IntelliJ IDEA, the plugin provides “minimalistic mode”. We can hide all tool windows and use the keyboard only for entities generation, Spring Data JPA repositories creation and edit, invoke DTO creation wizards, and so on. In addition to this, developers can use actions panel on the top of every editor to perform these actions:

Screenshot-2022-11-15-at-13.06.02

 

9. Smart Code Completion

To make developers even more productive, JPA Buddy allows code generation without changing a focus. With the smart code completion feature, a developer can create a new repository, add a method to an existing repository, and even create a DTO and a mapper without leaving the code editor. Buddy provides additional context-dependent postfixes to do this. Just by typing the entity class name and adding “.”, we can see all available methods that we can apply to the entity class:

Screenshot-2022-11-15-at-14.11.17

10. Conclusion

JPA Buddy provides a set of powerful tools that make JPA development easier. The good thing about the plugin is that it supports not only JPA but also related libraries used in data access layer development: Spring Data JPA, MapStruct, Lombok, and DB versioning solutions.

If we consider IntelliJ IDEA Community, this plugin can significantly simplify the work with JPA. IDEA Ultimate users can get some of the JPA Buddy functionality from the bundled plugins for JPA and Spring Framework support. Still, it looks like DB versioning script generation and DTOs creation features remain unique in DB development automation.

For those who prefer video format, there is a fifteen-minute recording showing JPA Buddy in action. We can see how to create an application with JPA Buddy and Spring Boot using IntelliJ IDEA:

Baeldung Pro – NPI EA (cat = Baeldung)
announcement - icon

Baeldung Pro comes with both absolutely No-Ads as well as finally with Dark Mode, for a clean learning experience:

>> Explore a clean Baeldung

Once the early-adopter seats are all used, the price will go up and stay at $33/year.

eBook – HTTP Client – NPI EA (cat=HTTP Client-Side)
announcement - icon

The Apache HTTP Client is a very robust library, suitable for both simple and advanced use cases when testing HTTP endpoints. Check out our guide covering basic request and response handling, as well as security, cookies, timeouts, and more:

>> Download the eBook

eBook – Java Concurrency – NPI EA (cat=Java Concurrency)
announcement - icon

Handling concurrency in an application can be a tricky process with many potential pitfalls. A solid grasp of the fundamentals will go a long way to help minimize these issues.

Get started with understanding multi-threaded applications with our Java Concurrency guide:

>> Download the eBook

eBook – Java Streams – NPI EA (cat=Java Streams)
announcement - icon

Since its introduction in Java 8, the Stream API has become a staple of Java development. The basic operations like iterating, filtering, mapping sequences of elements are deceptively simple to use.

But these can also be overused and fall into some common pitfalls.

To get a better understanding on how Streams work and how to combine them with other language features, check out our guide to Java Streams:

>> Join Pro and download the eBook

eBook – Persistence – NPI EA (cat=Persistence)
announcement - icon

Working on getting your persistence layer right with Spring?

Explore the eBook

Course – LS – NPI EA (cat=REST)

announcement - icon

Get started with Spring Boot and with core Spring, through the Learn Spring course:

>> CHECK OUT THE COURSE

Partner – Moderne – NPI EA (tag=Refactoring)
announcement - icon

Modern Java teams move fast — but codebases don’t always keep up. Frameworks change, dependencies drift, and tech debt builds until it starts to drag on delivery. OpenRewrite was built to fix that: an open-source refactoring engine that automates repetitive code changes while keeping developer intent intact.

The monthly training series, led by the creators and maintainers of OpenRewrite at Moderne, walks through real-world migrations and modernization patterns. Whether you’re new to recipes or ready to write your own, you’ll learn practical ways to refactor safely and at scale.

If you’ve ever wished refactoring felt as natural — and as fast — as writing code, this is a good place to start.

Course – LSD – NPI (cat=JPA)
announcement - icon

Get started with Spring Data JPA through the reference Learn Spring Data JPA:

>> CHECK OUT THE COURSE

eBook Jackson – NPI EA – 3 (cat = Jackson)