IntelliJ IDEA 2024.2 Help

JPA Buddy

JPA Buddy is an IntelliJ IDEA plugin that helps developers work efficiently with Hibernate, EclipseLink, Spring Data JPA, Flyway, Liquibase, Lombok, MapStruct, and other related technologies in both Java and Kotlin.

The plugin lowers the barrier to entry into development with JPA, boosts developer’s productivity, and makes sure your code follows best practices.

JPA Buddy provides:

You can use JPA Buddy in any project with Spring Boot, Jakarta Enterprise Edition, Quarkus, Micronaut, or even without any framework.

Install the JPA Buddy plugin

This functionality relies on the JPA Buddy plugin, which you need to install and enable.

  1. Press Ctrl+Alt+S to open settings and then select Plugins.

  2. Open the Marketplace tab, find the JPA Buddy plugin, and click Install (restart the IDE if prompted).

Install a specific version of the JPA Buddy plugin

Every version of JPA Buddy supports a range of IntelliJ IDEA versions. For example, JPA Buddy 2023.1 works correctly with IntelliJ IDEA 2022.2, 2022.3, and 2023.1. If you need to install JPA Buddy on the other version of IntelliJ IDEA, you need to install the plugin from disk.

  1. Open the Versions tab on the JPA Buddy page in JetBrains Marketplace.

  2. Download the version of the plugin compatible with your version of IntelliJ IDEA.

  3. Press Ctrl+Alt+S to open settings and then select Plugins.

  4. On the Plugins page, click The Settings button and then click Install Plugin from Disk.

    Install Plugin from Disk
  5. Select the plugin archive file and confirm your selection.

  6. Click OK to apply the changes and restart the IDE if prompted.

Dependencies

JPA Buddy scans the project dependencies and enables the corresponding features. In a multi-module project, features are enabled based on the presence of the dependency within the module, not the entire project.

Dependency

Features

Hibernate

  • Create and edit entities, entity attributes, lifecycle callbacks, indexes, and constraints in both Java and Kotlin.

  • Assign JPA converters and Hibernate custom types.

  • Apply Lombok annotations to entities.

  • Generate proper equals, hashCode, and toString.

EclipseLink

Spring Data JPA

  • Create repositories for entities.

  • Generate queries using visual constructors.

  • Extract JPQL from derived method queries.

  • Pick which fields to return from queries and generate projections.

Hibernate Validator

Add Hibernate Validator annotations to Entity and DTO attributes via JPA Designer and DTO generator wizard respectively.

Spring Boot Starter Validation

Hibernate Types

Assign Hibernate Custom Types to attributes via a code inspection with a quick fix (Alt+Enter).

Liquibase

  • Automatically generate Liquibase changelogs by comparing JPA model to a target database, model to snapshot, or DB to DB.

  • Use visual designers for Liquibase changelogs

  • Use coding assistance and autocomplete in Liquibase changelogs for table and column names. JPA Buddy takes these values directly from your data model.

Flyway

  • Generate Flyway migrations by comparing JPA model to a target database, model to snapshot, or DB to DB.

  • Scaffold INSERT, UPDATE, and DELETE statements for your entities in SQL files.

MapStruct

Create MapStruct mappers to convert entities to DTOs and back.

Blazebit Persistence Entity View API

Create Blaze Persistence Entity View for JPA Entity.

Blazebit Persistence Integration Spring Data Base

Create Spring Data JPA repository for Blaze Persistence Entity View.

Hibernate Envers

  • Generate database migration scripts for audit tables.

  • Create Spring Data JPA revision repositories.

  • Annotate entities and their fields for auditing via JPA Designer.

  • Generate @RevisionEntity via convenient wizard.

JPA Buddy visual tools

If JPA Buddy detects one of the supported dependencies, you can use the following visual tools:

JPA Buddy visual tools
  1. Editor toolbar

  2. JPA Designer tool window

Issue Tracker

If you find a bug in JPA Buddy or want to suggest a feature or an improvement, feel free to create a ticket on YouTrack.

Last modified: 04 July 2024