# Hibernate console

> **TL;DR**
> Required plugins: [Jakarta EE: Persistence (JPA)](https://plugins.jetbrains.com/plugin/20202) and [Hibernate](https://plugins.jetbrains.com/plugin/20214) (both bundled)

Use the Hibernate console to write and run HQL queries. It provides useful highlighting and completion for JPQL keywords, object, and property names.

> **Note:**
> Your project should use JDK 8 or later for the Hibernate console to be available.

> **Note:**
> A dedicated tool window, Hibernate Console is available if your project has the Hibernate facet. Otherwise, the [JPA Console](using-jpa-console.html) is used for both JPQL and HQL queries.

> **Tip:**
> Associate your session factories with the corresponding [data sources](managing-data-sources.html#data_sources). Otherwise, you will have to manually specify the database connection settings when using the JPA console. For more information, refer to [Associate persistence units with data sources](persistence-tool-window.html#assign_data_source).
>
>
>
>
>
> If you are using custom entity class or database table name mappings PostgreSQL that are not fully reflected in your code and configuration files, specify the corresponding `NamingStrategy` implementation, refer to [Associate persistence units with naming strategies](persistence-tool-window.html#assign_naming_strategy).

Procedure: Open the Hibernate console

* In the [Persistence](persistence-tool-window.html) tool window, right-click a session factory or entity and select JPA Console. Alternatively, you can click ![The Console button](https://resources.jetbrains.com/help/img/idea/2026.2/database-plugin.icons.expui.consoleRun.svg) in the toolbar or press `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)).

The Hibernate console input pane opens as a separate tab where you can write and execute HQL queries.

The Hibernate console toolbar contains the following buttons:

| ![Execute Query](https://resources.jetbrains.com/help/img/idea/2026.2/app-client.expui.run.run.svg) | `Ctrl+Enter` (Windows), `⌘ ⏎` (macOS), `⌘ ⏎` (IntelliJ IDEA Classic (macOS)), `⌘ ⏎` (macOS System Shortcuts), `Ctrl+Enter` (XWin), `Ctrl+Enter` (GNOME), `Ctrl+Enter` (KDE), `Ctrl+Enter` (Emacs), `Ctrl+Enter` (Sublime Text), `⌘ ⏎` (Sublime Text (macOS)), `Ctrl+Enter` (NetBeans), `Ctrl+Enter` (Visual Studio), `⌘ ⏎` (Visual Studio (macOS)), `Ctrl+Enter` (Eclipse), `⌘ ⏎` (Eclipse (macOS)) | Run the current query. |
| ![Open Database Settings](https://resources.jetbrains.com/help/img/idea/2026.2/app.expui.general.settings.svg) |  |  Open the [Database page](settings-tools-database.html) of the Settings dialog `Ctrl+Alt+S` (Windows), `⌘ Comma` (macOS), `⌘ Comma` (IntelliJ IDEA Classic (macOS)), `⌘ Comma` (macOS System Shortcuts), `Ctrl+Alt+S` (XWin), `Ctrl+Alt+S` (GNOME), `Ctrl+Alt+S` (KDE), `Ctrl+Alt+S` (Emacs), `Ctrl+Alt+S` (Sublime Text), `⌘ Comma` (Sublime Text (macOS)), `Ctrl+Alt+S` (NetBeans), `Ctrl+Alt+S` (Visual Studio), `⌘ Comma` (Visual Studio (macOS)), `Ctrl+Alt+S` (Eclipse), `⌘ Comma` (Eclipse (macOS)).  |
| ![View Parameters](https://resources.jetbrains.com/help/img/idea/2026.2/app.expui.nodes.parameter.svg) |  |  Open the Parameters pane to see the parameters used in your queries and set their values.  |
| ![Browse Query History](https://resources.jetbrains.com/help/img/idea/2026.2/app.expui.general.history.svg) | `Ctrl+Alt+E` (Windows), `⌘ ⌥ E` (macOS), `⌘ ⌥ E` (IntelliJ IDEA Classic (macOS)), `⌘ ⌥ E` (macOS System Shortcuts), `Ctrl+Alt+E` (XWin), `Ctrl+Alt+E` (GNOME), `Ctrl+Alt+E` (KDE), `Ctrl+Alt+E` (Emacs), `Ctrl+Alt+E` (Sublime Text), `⌘ ⌥ E` (Sublime Text (macOS)), `Ctrl+Alt+E` (NetBeans), `Ctrl+Alt+E` (Visual Studio), `⌘ ⌥ E` (Visual Studio (macOS)), `Ctrl+Alt+E` (Eclipse), `⌘ ⌥ E` (Eclipse (macOS)) | Open the console history dialog that shows all the queries that you have run in this console. |
| ![Restore Default Layout](https://resources.jetbrains.com/help/img/idea/2026.2/app.expui.general.layout.svg) |  | Restore the original tool window layout after layout changes. |
|  ![Select Properties Source](https://resources.jetbrains.com/help/img/idea/2026.2/app.expui.actions.preview.svg)  |  | Select the source for properties (available if a persistence unit is configured outside of `persistence.xml`).  |
| ![Terminate Process](https://resources.jetbrains.com/help/img/idea/2026.2/app.expui.run.stop.svg) | `Ctrl+F2` (Windows), `⌘ F2` (macOS), `⌘ F2` (IntelliJ IDEA Classic (macOS)), `⌃ ⇧ .` (macOS System Shortcuts), `Ctrl+F2` (XWin), `Ctrl+F2` (GNOME), `Ctrl+2` (KDE), `Ctrl+F2` (Emacs), `Ctrl+F2` (Sublime Text), `Ctrl+F2` (Sublime Text (macOS)), `Shift+F5` (NetBeans), `Shift+F5` (Visual Studio), `⇧ F5` (Visual Studio (macOS)), `Ctrl+F2` (Eclipse), `⌘ F2` (Eclipse (macOS)) | Terminate the current console session. |
| ![Close](https://resources.jetbrains.com/help/img/idea/2026.2/app.expui.general.close.svg) | `Ctrl+Shift+F4` (Windows), `⌃ ⇧ F4` (macOS), `⌘ ⇧ F4` (IntelliJ IDEA Classic (macOS)), `⌃ ⇧ F4` (macOS System Shortcuts), `Ctrl+Shift+F4` (XWin), `Ctrl+Shift+F4` (GNOME), `Ctrl+Shift+4` (KDE), `Ctrl+Shift+F4` (Emacs), `Ctrl+Shift+F4` (Sublime Text), `⌃ ⇧ F4` (Sublime Text (macOS)), `Ctrl+Shift+F4` (NetBeans), `Ctrl+Shift+F4` (Visual Studio), `⌃ ⇧ F4` (Visual Studio (macOS)), `Ctrl+W` (Eclipse), `⌘ W` (Eclipse (macOS)) | Close the current console. |

Procedure: Run HQL queries

After you write a query, do one of the following:

* Press `Ctrl+Enter` (Windows), `⌘ ⏎` (macOS), `⌘ ⏎` (IntelliJ IDEA Classic (macOS)), `⌘ ⏎` (macOS System Shortcuts), `Ctrl+Enter` (XWin), `Ctrl+Enter` (GNOME), `Ctrl+Enter` (KDE), `Ctrl+Enter` (Emacs), `Ctrl+Enter` (Sublime Text), `⌘ ⏎` (Sublime Text (macOS)), `Ctrl+Enter` (NetBeans), `Ctrl+Enter` (Visual Studio), `⌘ ⏎` (Visual Studio (macOS)), `Ctrl+Enter` (Eclipse), `⌘ ⏎` (Eclipse (macOS)).

* Click ![The Execute Query button](https://resources.jetbrains.com/help/img/idea/2026.2/app-client.expui.run.run.svg) in the toolbar.

When you execute a query with parameters, you will need to enter their values. Alternatively, click ![The View Parameters button](https://resources.jetbrains.com/help/img/idea/2026.2/app.expui.nodes.parameter.svg) to open the Parameters pane.

IntelliJ IDEA stores all queries that you execute. Press `Up` (Windows), `↑` (macOS), `↑` (IntelliJ IDEA Classic (macOS)), `↑` (macOS System Shortcuts), `Up` (XWin), `Up` (GNOME), `Up` (KDE), `Up` (Emacs), `Up` (Sublime Text), `↑` (Sublime Text (macOS)), `Up` (NetBeans), `Up` (Visual Studio), `↑` (Visual Studio (macOS)), `Up` (Eclipse), `↑` (Eclipse (macOS)) to see the previously executed commands, starting from the most recent one. To see the full history, click ![The Browse Query History button](https://resources.jetbrains.com/help/img/idea/2026.2/app.expui.general.history.svg).

Procedure: Navigate to the declaration of a class or field

When composing a query, it is useful to look at the declaration of the corresponding class or field.

* Hold `Ctrl` (Windows), `Ctrl` (macOS), `Ctrl` (IntelliJ IDEA Classic (macOS)), `Ctrl` (macOS System Shortcuts), `Ctrl` (XWin), `Ctrl` (GNOME), `Ctrl` (KDE), `Ctrl` (Emacs), `Ctrl` (Sublime Text), `Ctrl` (Sublime Text (macOS)), `Ctrl` (NetBeans), `Ctrl` (Visual Studio), `Ctrl` (Visual Studio (macOS)), `Ctrl` (Eclipse), `Ctrl` (Eclipse (macOS)) and click the relevant object or property.

* Place the caret at the name of the relevant object or property and press `Ctrl+B` (Windows), `⌘ B` (macOS), `⌘ B` (IntelliJ IDEA Classic (macOS)), `⌘ B` (macOS System Shortcuts), `Ctrl+B` (XWin), `Ctrl+B` (GNOME), `Ctrl+B` (KDE), `Ctrl+Alt+G` (Emacs), `F12` (Sublime Text), `F12` (Sublime Text (macOS)), `Ctrl+B` (NetBeans), `F12` (Visual Studio), `F12` (Visual Studio (macOS)), `F3` (Eclipse), `F3` (Eclipse (macOS)) or select `Navigate | Go to Declaration` from the main menu.

## Run the Hibernate console with custom JVM options

The Hibernate console is a Java process. If necessary, you can start it with custom JVM options:

Procedure:

1. Create an Application run configuration

Go to `Run | Edit Configurations`, click ![the Add button](https://resources.jetbrains.com/help/img/idea/2026.2/app.expui.general.add.svg), and select Application.

2. In the VM options field, specify the options that you want to pass to the JVM when it starts. The rest of the run configuration settings don't matter, and you don't need to specify them.

Click OK to save the run configuration.

3. When you [open the Hibernate console](#open-hibernate-console), IntelliJ IDEA will display an additional VM and Env Configuration popup with the available run configurations. Select the one with the necessary JVM options or run with the default settings.

