IntelliJ IDEA 2026.2 Help

JPA console

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

Make sure that persistence.xml contains the necessary information for the persistence unit to be able to run JPQL queries from the corresponding JPA console: the persistence provider, a list of persistent classes, and connection properties. For example, in the case of EclipseLink and MySQL, it could be similar to the following:

<persistence-unit name="NewPersistenceUnit"> <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider> <class>com.example.MyApp.models.ProductsEntity</class> ... <properties> <property name="eclipselink.jdbc.url" value="jdbc:mysql://localhost:3306/database"/> <property name="eclipselink.jdbc.driver" value="com.mysql.jdbc.Driver"/> <property name="eclipselink.jdbc.user" value="root"/> <property name="eclipselink.jdbc.password" value="root"/> </properties> </persistence-unit>

Open the JPA console

Do any of the following:

  1. In the Persistence tool window, right-click a persistence unit or entity and select JPA Console. Alternatively, you can click The Console button in the toolbar or press Ctrl+Shift+F10.

  2. Run query methods right from the editor.

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

The JPA console toolbar contains the following buttons:

Execute Query

Ctrl+Enter

Run the current query.

Open Database Settings

Open the Database | Query execution page of the Settings dialog Ctrl+Alt+S.

View Parameters

Open the Parameters pane to see the parameters used in your queries and set their values.

Browse Query History

Ctrl+Alt+E

Open the console history dialog that shows all the queries that you have run in this console.

Restore Default Layout

Restore the original tool window layout after layout changes.

Select Properties Source

Select the source for properties (available if a persistence unit is configured outside of persistence.xml).

Terminate Process

Ctrl+F2

Terminate the current console session.

Close

Ctrl+Shift+F4

Close the current console.

Run JPQL queries

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

  • Press Ctrl+Enter.

  • Click The Execute Query button in the toolbar.

When you execute a query with parameters, you will need to enter their values. Alternatively, click The View Parameters button to open the Parameters pane.

IntelliJ IDEA stores all queries that you execute. Press Up to see the previously executed commands, starting from the most recent one. To see the full history, click The Browse Query History button.

Run Spring Data query methods from the editor

If your project uses Spring Data, you can run your repository methods right from the editor. This lets you test your queries without having to run the entire application. This feature is available for the following method types:

  • Methods where the query is derived from the method name

  • Methods annotated with @Query that define explicit JPQL or SQL queries

  • Methods annotated with @NativeQuery that define explicit SQL queries

  • Methods where the name references a @NamedQuery or a @NamedNativeQuery declared in the repository's entity class

  1. Open a repository in the editor.

  2. In the gutter, click Console icon Run query in console next to a query method.

  3. If the query accepts parameters, the Parameters dialog opens. Specify the values and click Execute.

Convert Spring Data JPA method to JPQL

IntelliJ IDEA automatically runs the query against the data source from the Database tool window. If there is more than one data source, the IDE selects the first match from the following: query console attached to the file, running Spring Debugger session, assignment in the Persistence tool window, or data source URL in Spring Boot configuration files.

If you ran a JPQL query, the IDE opens the query's results in the JPA Console. If you ran a native SQL query, it opens the results in the Services tool window instead.

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

  • Hold Ctrl and click the relevant object or property.

  • Place the caret at the name of the relevant object or property and press Ctrl+B or select Navigate | Go to Declaration from the main menu.

Use the JPA console with custom JVM options

The JPA Console runs in a separate Java process. You can run this process with custom JVM options by creating a run configuration and then selecting it when you open the console.

  1. Open the Run/Debug Configurations dialog:

    • In the main toolbar, click the run widget and select Edit Configurations….

    • Alternatively, go to Run | Edit Configurations….

  2. On the left side of the dialog, select Add New Configuration icon Add New Configuration | Application icon Application.

  3. On the right side of the dialog, select Modify options | Add VM options.

  4. In the VM options field, specify the options that you want to pass to the JVM when opening the JPA Console.

    VM options field in the Run/Debug Configurations dialog populated with -Xmx512m

    You can also set up other run configuration settings, but it is not required for the JPA Console.

  5. Click Apply and then OK.

  6. Go to the Persistence tool window.

  7. In the tool window toolbar, select JPA Console icon JPA Console | Application icon <Your Configuration Name>.

    Run configuration toolbar
  8. The JPA Console opens with your JVM options applied. You can now run JPQL queries.

27 August 2026