IntelliJ IDEA 2019.1 Help

Hibernate Console Tool Window

From the Persistence tool window (for a session factory or any node within it):

  • database openapi icons consoleRun svg on the title bar

  • Console from the context menu

  • Ctrl+Shift+F10

When you open the Hibernate Console tool window, first, the input pane opens. This is where you compose your HQL queries.

HConsoleInput

When you run your first query (icons toolwindows toolWindowRun svg), the output pane opens above the input pane. Basically, this is the log of operations performed in the console.

If your query retrieves data (e.g. from, select), also the Result pane opens showing the retrieved data in table format.

HConsoleInputOutputResult

Additionally, you can open the Parameters pane (property yellow) to manage parameters in your queries.

HConsoleInputOutputResultParams

On this page:

See also, Working with the Hibernate 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

icons toolwindows toolWindowRun svg Execute Query

Ctrl+Enter

Use this icon or shortcut to run the current query.

icon sqlCopyQuery Generate SQL

Ctrl+Shift+Enter Use this icon or shortcut to generate an SQL equivalent of the current query.

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

Generate DDL

Ctrl+Shift+Alt+Enter Use this icon or shortcut to generate DDL SQL statements (CREATE TABLE, ALTER TABLE and DROP TABLE) for all the objects (classes) associated with the corresponding session factory.

The generated statements will be shown in the output pane.

icons vcs history Ctrl+Alt+E Use this icon or shortcut to open a dialog that shows all the queries that you have run in the console.

See also, Running auto-memorized queries.

icons general settings svg Settings

Use this icon to 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.

property yellow View Parameters

Use this icon to open or close the Parameters pane.

DBConsoleTWLayout Restore Layout

Use this icon to restore the original tool window layout (after the rearrangements that you have made).

icons actions suspend svg Terminate Process

Ctrl+F2

Use this icon or shortcut to terminate execution of the current query.

icons actions close Close

Ctrl+Shift+F4

Use this icon or shortcut to close the console.

Output pane

This pane shows the queries that you have run as well as the information about their execution. When errors occur, the corresponding information is also shown in this pane.

For most of the events the following information is provided:

  • Timestamp, that is, when the event took place.

  • For data manipulation operations - how many rows were affected (e.g. changed or deleted). For data retrieval operations - how many rows were retrieved.

  • Duration in milliseconds.

Use the following context menu commands:

  • Copy (Ctrl+C) to copy the text selected in the output pane to the clipboard.

  • Compare with Clipboard to compare the text selected in the output pane with the contents of the clipboard.

  • Clear All to clear all the contents of the output pane.

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 means of controls on the toolbar, context menu commands for the data cells, and associated keyboard shortcuts.

Item

Shortcut

Description

dataSourceTableEditorFirstPage, dataSourceTableEditorPreviousPage, dataSourceTableEditorNextPage and dataSourceTableEditorLastPage

These icons and corresponding commands are for switching between the result set pages, i.e. the pages that show the retrieved data.

A fixed number of rows shown simultaneously is 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.

In such cases, you can use dataSourceTableEditorFirstPage, dataSourceTableEditorPreviousPage, dataSourceTableEditorNextPage and dataSourceTableEditorLastPage to switch between the subsets. (If all the rows are currently shown, these icons and the corresponding commands are inactive.)

The result set page size is set on the Database page of the Settings dialog.

dataSourceTableEditorFirstPage First Page

Use this icon or command to switch to the first of the result set pages to see the first series of rows.

dataSourceTableEditorPreviousPage Previous Page

Ctrl+Alt+Up

Use this icon, command or shortcut to switch to the previous result set page to see the previous series of rows.

dataSourceTableEditorNextPage Next Page

Ctrl+Alt+Down

Use this icon, command or shortcut to switch to the next result set page to see the next series of rows.

dataSourceTableEditorLastPage Last Page

Use this icon or command to switch to the last of the result set pages to see the last series of rows.

icons actions refresh svg Reload Page

Ctrl+F5 Use this icon, command or shortcut to refresh the current table view. Use this function to:
  • Synchronize the data shown with the actual contents of the database.

  • Apply the Result set page size setting after its change.

DataExtractorButton Data Extractor: <current_format>

Use this button or command to open a menu in which you can select an output format for your data.

In addition to output formats, there are also the following options and commands:

  • Allow Transposition. For delimiter-separated values formats (TSV, CSV): If the table is shown transposed and you are copying selected cells or rows to the clipboard (e.g.Ctrl+C), the selection is copied transposed (as shown) if the option is on and non-transposed (as in the original table) otherwise.

  • Skip Generated Columns (SQL). For SQL INSERTs and UPDATEs: When copying or saving data, don't include auto-increment fields.

  • Add Table Definition (SQL). For SQL INSERTs and UPDATEs: When copying or saving data, add the table definition (CREATE TABLE).

  • Configure CSV Formats. Open the CSV Formats dialog that lets you manage your delimiter-separated values formats (e.g. CSV, TSV).

  • Go to Scripts Directory. Switch to the directory where the scripts that convert table data into various output formats are stored.

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

Use this command to save the 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

Use this command or shortcut to switch to a specified row. In the dialog that opens, specify the row number to go to.

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: 20 June 2019

See Also