# Persistence tool window

> **TL;DR**
> `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)](https://plugins.jetbrains.com/plugin/20202) plugin.
>
>
>
> If you use IntelliJ IDEA without the Ultimate subscription, you can install the [JPA
> Buddy](jpa-buddy.html) 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](#create-persistence-unit), 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](#create-mapping-context).

* Spring Data MongoDB: view MongoDB `@Document` classes.

* Liquibase: view Liquibase changelogs, create new ones, and run Liquibase update.

![The Persistence tool window](https://resources.jetbrains.com.cn/help/img/idea/2026.2/persistence_tool_window_with_jdbc.png)

> **Tip:**
> In IntelliJ IDEA Ultimate, if the [JPA Buddy](jpa-buddy.html) plugin is installed, you can also generate DTOs from the Persistence tool window.

Procedure: Open Entity in Persistence view

1. In the gutter, click an entity icon ![The Entity icon](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app.icons.javaee.newui.persistenceEntity%4014x14.svg). If you want to navigate to a particular field, click the corresponding icon next to it, such as ![The attribute icon](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app.icons.javaee.newui.persistenceAttribute%4014x14.svg) or ![The reference icon](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app.icons.javaee.newui.persistenceRelationship%4014x14.svg).

2. Select Select in Persistence View.

![Select in Persistence View](https://resources.jetbrains.com.cn/help/img/idea/2026.2/jpa_entity_open_in_persistence.png)

Alternatively, place the caret at your entity source code and click ![](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app-client.expui.general.locate.svg) in the Persistence tool window.

Procedure: Navigate to entity definitions

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` (Windows), `⌘ ↓` (macOS), `F4` (IntelliJ IDEA Classic (macOS)), `F4` (macOS System Shortcuts), `F4` (XWin), `F4` (GNOME), `F4` (KDE), `F4` (Emacs), `F4` (Sublime Text), `F4` (Sublime Text (macOS)), `F4` (NetBeans), `F4` (Visual Studio), `⌘ ↓` (Visual Studio (macOS)), `F12` (Eclipse), `F3` (Eclipse (macOS)).

* Right-click a field or class and select Jump to Source.

Procedure: Create Persistence Unit manually

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.

1. In the Persistence tool window, right-click JPA.

2. Select `New | Persistence Unit`.

3. 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 ![](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app-client.expui.general.add.svg) to add the classes to be mapped.

![Mapping Context](https://resources.jetbrains.com.cn/help/img/idea/2026.2/jpa_add_persistence_unit_manually.png)

Procedure: Create JDBC mapping context manually

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.

1. In the Persistence tool window, right-click Spring Data JDBC.

2. Select `New | Mapping Context`.

3. 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 ![](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app-client.expui.general.add.svg) to add the classes to be mapped.

![Mapping Context](https://resources.jetbrains.com.cn/help/img/idea/2026.2/jdbc_add_context_from_persistence_unit.png)

Procedure: View entity relationship diagrams (ERD)

* Right-click a managed entity and select Entity Relationship Diagram.

Procedure: Associate persistence units with data sources

1. Right-click a module, persistence unit, or entity, and select Assign Data Sources….

2. Select necessary [data sources](managing-data-sources.html#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](using-jpa-console.html) will use proper database connection settings, and you won't need to specify them manually.

Procedure: Associate persistence units with naming strategies

1. Right-click a module, persistence unit, or entity, and select Assign Naming Strategies….

2. Select necessary naming strategies for relevant persistence units and click OK.

Procedure: Run JPQL queries

* Right-click a persistence unit or entity and select JPA Console or click ![The Console button](https://resources.jetbrains.com.cn/help/img/idea/2026.2/database-plugin.icons.expui.consoleRun.svg) in the toolbar `Ctrl+Shift+F10` (Windows), `⌘ ⇧ F10` (macOS), `⌘ ⇧ F10` (IntelliJ IDEA Classic (macOS)), `⌘ ⇧ F10` (macOS System Shortcuts), `Ctrl+Shift+F10` (XWin), `Ctrl+Shift+F10` (GNOME), `Ctrl+Shift+F10` (KDE), `Ctrl+Shift+F10` (Emacs), `Ctrl+Shift+F10` (Sublime Text), `⌘ ⇧ F10` (Sublime Text (macOS)), `Ctrl+Shift+F10` (NetBeans), `Ctrl+Shift+F10` (Visual Studio), `⌘ ⇧ F10` (Visual Studio (macOS)), `Ctrl+Shift+F10` (Eclipse), `⌘ ⇧ F10` (Eclipse (macOS)).

This will open the [JPA console](using-jpa-console.html) where you can write and execute JPQL queries.

## Reverse engineer a database schema

With IntelliJ IDEA, you can create JPA entity classes and attributes based on an existing database schema. This functionality relies on the [Reverse Engineering](reverse-engineering.html) plugin, which is bundled in IntelliJ IDEA Ultimate.

Procedure: Generate entities from a database

1. Make sure IntelliJ IDEA is [connected
to your database](managing-data-sources.html#create_a_data_source).

> **Tip:**
> If your project uses [Spring](spring-support.html), [Micronaut](micronaut.html), or [Quarkus](quarkus.html), you can quickly create a database connection right from your configuration file (`application.properties` or `application.yml`).
>
>
>
> To do so, open the file in the editor and click  ![Database connection icon](https://resources.jetbrains.com.cn/help/img/idea/2026.2/javaee-persistence-impl.icons.expui.add-db-from-config.svg) Create new datasource from existing properties  in the editor gutter.

2. In the [Persistence]() tool window, right-click a persistence unit or mapping context, and select `![Plus icon](https://resources.jetbrains.com.cn/help/img/idea/2026.2/intellij.platform.ide.expui.general.add.svg) New | ![Database icon with a blue table](https://resources.jetbrains.com.cn/help/img/idea/2026.2/intellij.platform.ide.expui.javaee.persistenceEntity.svg) JPA Entities from DB`.

3. In the [JPA Entities from DB dialog](reverse-engineering.html#entities-from-db-dialog) that opens, configure the entity mappings and click OK.

Procedure: Generate entity attributes from a database

You can also generate attributes for an existing class based on a database table.

1. Make sure IntelliJ IDEA is [connected
to your database](managing-data-sources.html#create_a_data_source).

2. In the [Persistence]() tool window, right-click an entity, and select `![Plus icon](https://resources.jetbrains.com.cn/help/img/idea/2026.2/intellij.platform.ide.expui.general.add.svg) New | ![Database icon with a blue table](https://resources.jetbrains.com.cn/help/img/idea/2026.2/intellij.platform.ide.expui.javaee.persistenceEntity.svg) Entity Attributes from DB`.

3. In the [JPA Entities from
DB dialog](reverse-engineering.html#entities-from-db-dialog) that opens, configure the entity mappings and click OK.

