IntelliJ IDEA 2020.2 Help

Enable Hibernate

Make sure the Hibernate plugin is enabled

  1. In the Settings / Preferences dialog Ctrl+Alt+S, select Plugins.

  2. Type Hibernate in the search box to locate the necessary plugin in the list.

  3. If the checkbox next to Hibernate is not selected, select it to enable the plugin.

  4. Click OK. If suggested, restart IntelliJ IDEA.

Enabling the Hibernate plugin

Enable Hibernate support for a project or module

  1. Launch IntelliJ IDEA.

    If the Welcome screen opens, click Create New Project.

    Otherwise, from the main menu, select File | New | Project or Module.

  2. Select Java or Java Enterprise from the list on the left.

  3. From the Project SDK list, select the JDK that you want to use in your project.

    If the JDK is installed on your computer, but not defined in the IDE, select Add JDK and specify the path to the JDK home directory.

    If you don't have the necessary JDK on your computer, select Download JDK.

  4. (For Java Enterprise) Specify the necessary JavaEE version and select the server from the list. If the Application server list is empty, click New and configure a new server.

  5. Under Additional Libraries and Frameworks, select the Hibernate checkbox.

  6. If necessary, select the Create default hibernate configuration and main class to create a configuration file hibernate.cfg.xml and a main class (a class with a main() method that outputs the records for your managed entities).

  7. If there is a database defined in IntelliJ IDEA as a data source, select the Import database schema option. This will create the necessary entity classes and object/relational mappings for them.

  8. Select the required library option and click Next.

    Creating a new Hibernate project

  9. Specify the project name and location. Click Finish.

If you selected to import a database schema, the Import Database Schema dialog opens, and you can specify the entity classes to be generated and associated settings.

Enable Hibernate support for an existing module

  1. In the Project tool window, right-click the necessary module and select Add Frameworks Support.

  2. In the dialog that opens, select the Hibernate checkbox.

  3. If necessary, select the Create default hibernate configuration and main class to create a configuration file hibernate.cfg.xml and a main class (a class with a main() method that outputs the records for your managed entities).

  4. If there is a database defined in IntelliJ IDEA as a data source, select the Import database schema option. This will create the necessary entity classes and object/relational mappings for them.

  5. Select the required library option and click OK.

    Adding Hibernate support to a module

If you selected to import a database schema, the Import Database Schema dialog opens, and you can specify the entity classes to be generated and associated settings.

Last modified: 08 May 2020