JPA represents the anemic domain model pattern. So, usually, the main domain objects are layered as follows:
Such segregation looks natural because each layer has its clear responsibility area. However, it brings additional complexity during development due to bad discoverability for different operations available over entities.
JPA Buddy addresses this problem by integrating a lot of coding assistance features for JPA entities, Spring Data repositories, DTOs and MapStruct mappers that make development more straightforward and transparent.
To create a new Spring Data JPA repository just start typing the repository name that begins with the entity name (1). Then, the repository wizard will open.
By following the same coding style, you can also inject an existing Spring Data JPA repository (2). Just start typing the existing repository name and JPA Buddy will find it.
According to your injection settings, JPA Buddy will inject the repository into the current class. Example below shows constructor based injection:
With JPA Buddy, you don't need to switch focus between multiple editors. It allows to call query visual designers right from here:
Also, you can find/create repository methods via entity class name call:
JPA Buddy is able to generate MapStruct mapper, inject it, and scaffold a proper mapping call. Use "mapTo..." option to generate a new mapper, or apply methods from existing ones (e.g., "mapToPetDto" for the example below). This feature works for both: single instances and collections of entities or DTOs.
Here is the code that JPA Buddy will generate after selecting the "mapToPetDto" option:
Some developers prefer to declare an object that doesn't exist yet first and only then implement it. JPA Buddy will help those developers who adhere to this programming style. It suggests to create:
Then, corresponding wizards will open.
JPA Buddy provides flexible settings to make the use of coding assistance features even more handful. You can: