Persistence tool window
View | Tool Windows | Persistence
tip
If you use IntelliJ IDEA Ultimate, the Persistence tool window is built-in via the bundled Jakarta EE: Persistence (JPA) plugin.
If you use IntelliJ IDEA Community, you can install the JPA Buddy plugin to enable the Persistence tool window.
If you have a JPA or Spring Data dependency in your project, you can use the Persistence tool window. Based on the dependencies of your project, it can show the following elements:
JPA: view and manage JPA items: configuration files, persistence units, managed entities (persistent classes and fields), Spring repositories, and JPA converters.
Spring Data JDBC: view JDBC-mapped entities, attributes, relations, and repositories; configure mapping contexts.
Spring Data MongoDB: view MongoDB
@Document
classes.Liquibase: view Liquibase changelogs, create new ones, and run Liquibase update.

tip
In IntelliJ IDEA Ultimate, if the JPA Buddy plugin is installed, you can also generate DTOs from the Persistence tool window.
In the gutter, click an entity icon
. If you want to navigate to a particular field, click the corresponding icon next to it, such as
or
.
Select Select in Persistence View.

Alternatively, place the caret at your entity source code and click in the Persistence tool window.
To navigate from an entity in the Persistence tool window to the corresponding source code definition in the editor, do one of the following:
Double-click a field.
Select a field or class and press F4.
Right-click a field or class and select Jump to Source.
In most cases, IntelliJ IDEA automatically detects JPA entities based on the @Entity
annotation. If it is not the case, you can create a persistence unit manually to add the necessary entities and map them to a database. The added entities will be available in the Persistence tool window, and from there, you can navigate to their source code definitions in the editor.
In the Persistence tool window, right-click JPA.
Select New | Persistence Unit.
In the Edit Persistence Unit window that opens, configure the mapping context: give the context a name, select the database connection, and under JPA Entities, click
to add the classes to be mapped.

In most cases, IntelliJ IDEA automatically detects JDBC entities based on the @Table
annotation or its JDBC repository. If it is not the case, you can create a mapping context manually to add the necessary JDBC entities and map them to a database. The added entities will be available in the Persistence tool window, and from there, you can navigate to their source code definitions in the editor.
In the Persistence tool window, right-click Spring Data JDBC.
Select New | Mapping Context.
In the Edit Mapping Context window that opens, configure the mapping context: give the context a name, select the database connection, and under JDBC Entities, click
to add the classes to be mapped.

Right-click a managed entity and select Entity Relationship Diagram.
Right-click a module, persistence unit, or entity, and select Assign Data Sources.
Select necessary data sources for relevant persistence units and click OK.
With this association, IntelliJ IDEA will validate the source code that references database tables against the corresponding data sources. Also, the JPA console will use proper database connection settings, and you won't need to specify them manually.
Right-click a module, persistence unit, or entity, and select Assign Naming Strategies.
Select necessary naming strategies for relevant persistence units and click OK.
Right-click a persistence unit or entity and select JPA Console or click
in the toolbar CtrlShiftF10.
This will open the JPA console where you can write and execute JPQL queries.
With IntelliJ IDEA, you can create JPA entity classes and attributes based on an existing database schema. This functionality relies on the Reverse Engineering plugin, which is bundled in IntelliJ IDEA Ultimate.
If a database connection is not established, create one.
note
In Spring, Micronaut, and Quarkus projects, you can quickly create a database connection right from your application.properties or application.yml file by clicking
in the gutter.
In the Persistence tool window, expand the JPA node, right-click an element, and select New | JPA Entities from DB.
Alternatively, right-click a database connection in the Database tool window, and select Create JPA Entities from DB.
Select a database connection, tables, and attributes to be mapped. For more information, refer to Entities from DB Wizard.
While your IDE is open, the database can be modified by other clients. To get the latest data from the database, you can click in either the Entities from DB window or in the Database tool window.
You can also generate attributes for an existing class based on a database table.
If a database connection is not established, create one.
In the Persistence tool window, expand the JPA node, right-click an entity and select New | JPA Entities from DB.
Alternatively, right-click a database connection in the Database tool window, and select Create JPA Attributes from DB.
Select a database connection, a table or a view, and columns to be mapped. The attributes migration flow is identical to what is described in the Entities from DB wizard section.
With IntelliJ IDEA, you can create @Document
classes and attributes based on an existing collections in MongoDB. This functionality relies on the Reverse Engineering plugin, which is bundled in IntelliJ IDEA Ultimate.
If a MongoDB connection is not established, create one.
note
In Spring, Micronaut, and Quarkus projects, you can quickly create a database connection right from your application.properties or application.yml file by clicking
in the gutter.
In the Persistence tool window, expand the Spring Data MongoDB node, right-click an element, and select New | MongoDB Documents from DB.
Alternatively, right-click a MongoDB connection in the Database tool window, and select Create MongoDB Documents from DB.
Select a database connection, tables, and attributes to be mapped. For more information, refer to Entities from DB Wizard.
While your IDE is open, the database can be modified by other clients. To get the latest data from the database, you can click in either the Entities from DB window or in the Database tool window.
You can also generate attributes for an existing class based on a MongoDB table.
If a database connection is not established, create one.
In the Persistence tool window, expand the Spring Data MongoDB node, right-click an entity and select New | MongoDB Fields from DB.
Alternatively, right-click a MongoDB connection in the Database tool window, and select Create MongoDB Fields from DB.
Select a database connection, a table or a view, and columns to be mapped. The attributes migration flow is identical to what is described in the Entities from DB wizard section.
note
If you map embedded (nested) MongoDB documents, IntelliJ IDEA automatically creates corresponding classes for documents inside other documents.
Thanks for your feedback!