IntelliJ IDEA 2019.2 Help

JPA Console Tool Window

From the Persistence tool window (for a persistence unit or any node within it):

  • database openapi icons consoleRun svg on the title bar

  • Console from the context menu

  • Ctrl+Shift+F10

The input pane of a database console opens as a separate editor tab. The input pane is where you compose your SQL statements.

When you execute a statement, the Services tool window opens. The Services tool window displays available connection sessions, Output and Result tabs. For more information about the Services tool windows, see Services Tool Window.

If the executed statement retrieves data (for example, SELECT), results are displayed in the Result tab that has a title of a qualified table name. For more information about creating custom titles for result tabs, see Use custom titles for tabs with results.

Use custom titles for tabs with results

Before execution of a parametrized statement, you see the Parameters window where you can specify values for the parameters.

On this page:

See also, Working with the JPA console.

Toolbar icons and shortcuts

Most of the functions in the Hibernate Console tool window are accessed by means of the toolbar icons and associated keyboard shortcuts.

Item

Shortcut

Description

the Execute button Execute Query

Ctrl+Enter

Run the current query.

icon sqlCopyQuery Generate SQL

Ctrl+Shift+Enter Generate an SQL equivalent of the current query.

The generated SQL statement will be shown in the output pane.

Generate Script Generate SQL/Generate DDL

Ctrl+Shift+Alt+Enter

Generate DDL SQL statements CREATE TABLE, ALTER TABLE and DROP TABLE for all the objects (classes) associated with the corresponding persistence unit.

The generated statements will be shown in the output pane.

Browse Console History Ctrl+Alt+E

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

See also, Running auto-memorized queries.

Settings Settings

Open the Database page of the Settings dialog to view or edit the settings for the database, Hibernate and JPA consoles, data editors, and the Database tool window.

View Parameters View Parameters

Open or close the Parameters dialog.

Restore Layout Restore Layout

Restore the original tool window layout after layout changes.

Cancel Query Terminate Process

Terminate execution of the current query.

Close Close

Ctrl+Shift+F4

Close the console.

Output pane

Use the Output tab to view information about queries that ran in IntelliJ IDEA. Also, the Output tab displays errors.

The Ouput tab

Right toolbar

Item

Description

Soft-wrap

Wrap long lines of text.

Scroll to end

Scroll the output log to the end.

Print

Print a database console file, a selected text, or all the files in a directory.

Clear all

Clear the Output tab.

Context menu

Item

Description

Copy Copy

Copy the selected text.

Copy as Plain Text

Copy the selected text as plain text (without formatting).

Copy Reference

Copy a reference link to a file or a line.

Compare with clipboard Compare with clipboard

Open the Clipboard vs Editor dialog where you can see the diff between the selected text and the text that you copied to a clipboard.

Search with Google

Open a browser and run a search on Google for the selected text.

Fold Lines Like This

Fold the lines that include the selected text.

Pause Output

Pause the output logging.

Clear All

Clear the output log.

Result pane

This pane shows the data retrieved from the database in table format. You can sort the data as well as perform other, associated tasks.

Most of the functions in the Result pane are accessed by using controls on the toolbar, context menu commands for the data cells, and associated keyboard shortcuts. You can see what other actions with tables you can perform in Working with tables.

Item

Shortcut

Description

First page, Previous page, Next page, Last page

Use navigation icons and corresponding commands for switching between pages that show the retrieved data.

A number of rows that you see simultaneously on the Result tab are referred to as a result set page. If this number is less than the number of rows that satisfy the query, only a subset of all the rows is shown at a time. If all the rows are currently shown, navigation icons and the corresponding commands are inactive.

  • First page: jump to the first page of results.

  • Previous page: go to the previous page of results.

  • Next page: go to the next page of results.

  • Last page: jump to the last page of results.

To change the size of a result set page, open settings (Ctrl+Alt+S) and navigate to Tools | Database | Data Views. In the Limit page size to field, type a new size of a result set page. Alternatively, to disable the page size restriction, clear the Limit page size to checkbox.

Reload page Reload Page

Ctrl+F5

Reload data for the table view to synchronize the data that you see in the editor with the contents of the database. Also, use the Reload Page button when you want to apply a new page size limit setting after its change.

Data Extractor Data Extractor

Select an output format for your data.

Also, you can configure the following options:

  • Skip Computed Columns (SQL): do not include virtual columns that are not physically stored in the table (for example, the identity column).

  • Skip Generated Columns (SQL): for INSERT and UPDATE statements, do not include auto-increment fields when copying or saving data.

  • Add Table Definition (SQL): for INSERT and UPDATE statements, add the table definition when copying or saving data.

  • Configure CSV Formats: open the CSV Formats dialog where you can manage your delimiter-separated values formats (for example, CSV, TSV).

  • Go to Scripts Directory: open a directory with scripts that convert table data into different output formats.

Copy All To Clipboard / Save All To File

  • Copy All To Clipboard. Use this command to copy the table data onto the clipboard.

  • Save All To File. Use this command to save the table data in a file. In the dialog that opens, specify the location and name of the file.

Note:

  • The data extractor which is currently active is applied.

  • If only a subset of corresponding rows is currently shown, all the appropriate rows are copied to the clipboard or saved in a file anyway. (The number of rows currently shown may be limited by the Result set page size parameter.)

Save LOB

Save a binary large object (LOB) currently selected in the table in a file.

Reset View

Use this command to restore the initial table view after reordering or hiding the columns, or sorting the data. As a result, the data, generally, becomes unsorted, the columns appear in the order in which they were defined initially, and all the columns are shown.

View Query

Use this button to view the query which was used to generate the table. To close the pane where the query is shown, press Escape.

Go To | Row

Ctrl+G

Jump to a specified row. In the Go to Row dialog, specify the column and row number (use the column:row pattern).

Using the header row. In the Result pane, you can use the cells in the header row (i.e. the row where column names are shown) for:

To sort table data in a column, click the cell in the header row.

State

Description

No sorting

Indicates that the data is not sorted in this column. The initial state of the sorting marker.

Ascending order

The data is sorted in the ascending order. The number to the right of the marker (1 on the picture) is the sorting level. You can sort by more than one column. In such cases, different columns will have different sorting levels.

Descending order

The data is sorted in the descending order.

Here is an example of a table where data are sorted by two of its columns.

TableEditorSortedTable

To restore the initial "unsorted" state for the table, click IconDBToolbarMenu and select Reset View.

To reorder columns, use drag-and-drop for the corresponding cells in the header row.

To hide a column, right-click the corresponding header cell and select Hide column.

Right-click any of the cells in the header row and select Column List. Alternatively, press Ctrl+F12. Select the hidden column and press Ctrl+F12

To hide a column, right-click the corresponding header cell and select Hide column.

To show a hidden column:

  1. Do one of the following:
    • Right-click any of the cells in the header row and select Column List.

    • Press Ctrl+F12.

    In the list that appears, the names of hidden columns are shown struck through.

    TableResultPaneHideColumn
  2. Select (highlight) the column name of interest and press Space.

  3. Press Enter or Escape to close the list.

To show all the columns, click IconDBToolbarMenu and select Reset View.

See also, Using the Structure view to sort data, and hide and show columns.

Parameters pane

The Parameters pane shows the parameters detected in the input pane and lets you edit their values. To open or close this pane, use property yellow on the toolbar.

Parameter values can be specified just as text or numbers, or as Groovy expressions that contain object references and method calls. For example, the value for the date parameter in the query

SELECT o FROM Order o WHERE o.date > :date

could be specified as

new java.sql.Date(System.currentTimeMillis() - 24*3600*1000)

To start editing a value, switch to the corresponding table cell and start typing. To indicate that you have finished editing a value, press Enter or switch to a different cell. To quit the editing mode and restore an initial value, press Escape.

When you select a row in the table, the corresponding parameter is highlighted in the input pane.

Last modified: 17 October 2019