# Exposed

> **TL;DR**
> Required plugin: Kotlin (bundled), Exposed
>
>
>
> [Install Exposed](jetbrains://idea/plugin/install?id=com.intellij.exposed)

[Exposed](https://www.jetbrains.com.cn/en-us/exposed/) is a lightweight SQL library for Kotlin that supports both JDBC and R2DBC drivers for blocking and reactive database access. It provides two APIs for working with databases: a type-safe SQL DSL and an object-oriented DAO API.

The Exposed plugin for IntelliJ IDEA provides a range of features to enhance your development experience with Exposed. These features include:

* [Code completion](#code-completion) for Exposed entities and tables.

* Database-aware [code inspections](#inspections).

* [Navigation](#navigate-to-mapped-reference) between code and database.

* [Generation](#code-generation) of Exposed table definitions and DAO entity classes.

* [Live templates](#live-templates).

Procedure: Install the Exposed plugin

This functionality relies on the [Exposed](https://plugins.jetbrains.com/plugin/24367-exposed)  plugin, which   you need to install and enable.

> **Note:**
> The Exposed plugin is not available in IntelliJ IDEA without the Ultimate subscription.

1. Press `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)) to open settings and then select `Plugins`.

2. Open the Marketplace tab, find the Exposed plugin, and click Install (restart the IDE if prompted).

## Configure a data source

Some Exposed plugin features use your database schema for [code generation](#code-generation), [code inspections](#inspections), and [navigation
to mapped references](#navigate-to-mapped-reference).

Before using these features, [configure a data source](managing-data-sources.html) in the Database tool window.

> **Note:**
> The plugin uses the SQL resolution scope to associate your Kotlin code with a data source. In most cases, IntelliJ IDEA configures this association automatically. If your project uses multiple data sources or the automatic association is incorrect, you can [manually configure the SQL resolution scope](settings-languages-sql-resolution-scopes.html).

## Code completion

The plugin improves code completion when working with Exposed entities and tables. This helps reduce the need to manually type repetitive property declarations.

## Database-aware code inspections

When a [database connection](connecting-to-a-database.html) and schema context are available from the Database tool window, the Exposed plugin uses it to validate references in Exposed table definitions and queries.

During code analysis, the plugin resolves database objects against the selected schema and reports inconsistencies such as unresolved tables, columns, foreign keys, and other schema-related references.

In the editor, IntelliJ IDEA highlights unresolved references, displays inspection warnings, and provides quick-fix suggestions. For example, if a table referenced in an Exposed definition cannot be found in the connected database schema, the plugin shows an inspection warning and a corresponding hint:

![A hint for unresolved table definition](https://resources.jetbrains.com.cn/help/img/idea/2026.2/exposed_plugin_unresolved_table.png)

To review or modify the schemas used for validation, select Go to SQL Resolution Scopes. This allows you to configure the database sources and schemas that IntelliJ IDEA uses for SQL resolution and validation.

> **Tip:**
> For more information about running and configuring inspections, see [Code inspections](code-inspection.html).

## Navigate to mapped tables and columns

The plugin adds gutter icons next to Exposed table and column declarations that allow you to navigate to the mapped reference in the Database tool window.

Procedure:

1. Open a file containing an Exposed table object.

2. Click the gutter icon next to the table definition.

3. Choose the Select in Database View option.

![Gutter icons for Exposed tables](https://resources.jetbrains.com.cn/help/img/idea/2026.2/exposed_plugin_select_db_view.png) IntelliJ IDEA opens the Database tool window and navigates to the corresponding table:

![Exposed plugin navigation to database view](https://resources.jetbrains.com.cn/help/img/idea/2026.2/exposed_plugin_select_db_view_open.png)

## Generate code

Procedure: Generate tables from an existing database schema

You can use the Database tool window to generate Exposed table definitions from existing database objects.

1. Open the Database tool window.

2. Right-click a schema, table, or other supported database element.

3. Choose Create Exposed Tables from DB .

If your project includes the `org.jetbrains.exposed:exposed-dao` dependency, choose Create Exposed Entities from DB.

![Generate tables from an existing database schema](https://resources.jetbrains.com.cn/help/img/idea/2026.2/exposed_plugin_generate_tables.png)

4. In the open dialog, you can select and customize the output, for example:

* Use the Target package field to specify where the generated tables or DAO entity classes will be placed.

* Review and modify the suggested property names.

* Adjust the inferred Exposed column types, if necessary. > **Note:** > Type mappings are inferred from database metadata and may require manual review, especially for vendor-specific or custom database types. ![Generate tables from an existing database schema](https://resources.jetbrains.com.cn/help/img/idea/2026.2/exposed_plugin_generate_tables_popup.png)

5. Click OK to generate the code.

Procedure: Generate entities from existing tables

You can use the plugin to generate DAO entity classes for an existing Exposed table object.

> **Note:**
> This feature requires the `org.jetbrains.exposed:exposed-dao` dependency.

1. Open a file containing an Exposed table object.

2. Click the gutter icon next to the table definition.

3. Select the Generate Exposed Entity from the Table option.

![Generate entities from existing tables](https://resources.jetbrains.com.cn/help/img/idea/2026.2/exposed_plugin_generate_entities.png)

The generated entity class is created in the same Kotlin file as the table object. The plugin generates both the `Entity` class and its companion `EntityClass`.

## Exposed live templates

The Exposed plugin provides [live templates](using-live-templates.html) that help you quickly create common Exposed code constructs in your Kotlin files. Live templates generate predefined code snippets based on the template name, reducing the amount of boilerplate code you need to write.

To expand a live template, type the corresponding abbreviation and press `Tab` (Windows), `⇥` (macOS), `⇥` (IntelliJ IDEA Classic (macOS)), `⇥` (macOS System Shortcuts), `Tab` (XWin), `Tab` (GNOME), `Tab` (KDE), `Tab` (Emacs), `Tab` (Sublime Text), `⇥` (Sublime Text (macOS)), `Tab` (NetBeans), `Tab` (Visual Studio), `⇥` (Visual Studio (macOS)), `Tab` (Eclipse), `⇥` (Eclipse (macOS)).

### Database templates

Use the following live templates to generate database-related code:

| Abbreviation | Description |
| --- | --- |
| `database` |  Generates a database connection configuration for Exposed JDBC.   > **Note:** > The `database` template requires the `org.jetbrains.exposed:exposed-jdbc` dependency.    |
| `r2dbcDatabase` |  Generates a database connection configuration for Exposed R2DBC.   > **Note:** > The `r2dbcDatabase` template requires the `org.jetbrains.exposed:exposed-r2dbc` dependency.    |

### Table templates

Use the following templates to generate Exposed table objects:

| Abbreviation | Description |
| --- | --- |
| `table` |  Generates a [Table](https://jetbrains.github.io/Exposed/api/exposed-core/org.jetbrains.exposed.v1.core/-table/index.html) object.  |
| `idTable` |  Generates an [IdTable](https://jetbrains.github.io/Exposed/api/exposed-core/org.jetbrains.exposed.v1.core.dao.id/-id-table/index.html) object.  |
| `intIdTable` |  Generates an [IntIdTable](https://jetbrains.github.io/Exposed/api/exposed-core/org.jetbrains.exposed.v1.core.dao.id/-int-id-table/index.html) object.  |
| `longIdTable` |  Generates a [LongIdTable](https://jetbrains.github.io/Exposed/api/exposed-core/org.jetbrains.exposed.v1.core.dao.id/-long-id-table/index.html) object.  |
| `uuidTable` |  Generates a [UuidTable](https://jetbrains.github.io/Exposed/api/exposed-core/org.jetbrains.exposed.v1.core.dao.id/-uuid-table/index.html) object.  |

### DAO entity templates

Use the following templates to generate Exposed DAO entity classes:

| Abbreviation | Description |
| --- | --- |
| `entity` |  Generates an `Entity` class.  |
| `intEntity` |  Generates an [IntEntity](https://jetbrains.github.io/Exposed/api/exposed-dao/org.jetbrains.exposed.v1.dao/-int-entity/index.html) class.  |
| `longEntity` |  Generates a [LongEntity](https://jetbrains.github.io/Exposed/api/exposed-dao/org.jetbrains.exposed.v1.dao/-long-entity/index.html) class.  |
| `uuidEntity` |  Generates a [UuidEntity](https://jetbrains.github.io/Exposed/api/exposed-dao/org.jetbrains.exposed.v1.dao/-uuid-entity/index.html) class.  |

> **Note:**
> The DAO entity templates require the `org.jetbrains.exposed:exposed-dao` dependency.

### Configure live templates

You can view and customize Exposed live templates in IntelliJ IDEA settings:

Procedure:

1. Press `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)) to open settings and then select `Editor | Live Templates`.

2. In the list of options, click the Exposed node to expand the list of provided live templates.

![Exposed Live Templates Settings](https://resources.jetbrains.com.cn/help/img/idea/2026.2/exposed_plugin_live_templates.png)

You can then enable and disable them using checkboxes, edit existing templates, and create new ones.

