IntelliJ IDEA 14.0.0 Web Help

Enabling Hibernate Support

To be able to use Hibernate support, you should:

  • Make sure that the Hibernate Support plugin is enabled. This plugin is bundled with the IDE and enabled by default. However, you may have disabled it for some reason by now.
  • Enable Hibernate support at a module level. You can do that when creating a new project, or when adding a new module to an existing project. You can also enable Hibernate support for an existing module.

On this page:

Making sure that the Hibernate Support plugin is enabled

  1. Open the Settings dialog (e.g. Ctrl+Alt+S).
  2. In the left-hand part of the dialog, under IDE Settings, select Plugins.
  3. In the right-hand part of the dialog, on the Plugins page, type hib in the search box. As a result, only the plugins whose names and descriptions contain hib are shown in the list of plugins.
  4. If the check box to the right of Hibernate Support is not selected, select it.
  5. Click OK in the Settings dialog.
  6. If suggested, restart IntelliJ IDEA.

Enabling Hibernate support when creating a project or module

  1. Do one of the following:
    • If you are going to create a new project: click Create New Project on the Welcome screen or select File | New Project.

      As a result, the New Project wizard opens.

    • If you are going to add a module to an existing project: open the project you want to add a module to, and select File | New Module.

      As a result, the New Module wizard opens.

  2. On the first page of the wizard, in the left-hand pane, select Java. In the right-hand part of the page, specify the JDK that you are going to use.
  3. Select the Hibernate check box.
  4. If necessary, select to create a configuration file (hibernate.cfg.xml) and a main class (a class with a main() method for running your application).

    If there is a database defined in IntelliJ IDEA as a data source, you can select to import the database schema. This will result in creating the necessary persistent Java classes and metadata.

  5. Select the required library option and, if necessary, specify the associated settings. You can choose to:
    • Download Hibernate implementation files and arrange those files in a library.

      To do that, under Libraries, select Download. Optionally, click Configure to edit the library settings. (The Downloading Options dialog will open.)

    • Use a library that is already defined IntelliJ IDEA.

      To do that, click Use library and select the required library from the list. Optionally, click Configure to edit the library settings. (The Edit Library dialog will open.)

    • Create a new library using the appropriate JAR files available on your computer.

      To do that, click Use library and then click Create. Select the required JAR files in the dialog that opens. (For multiple selection, keep the Ctrl key pressed.) Optionally, click Configure to edit the library settings. (The Create Library dialog will open.)

    • Postpone setting up the library until a later time. In this case, select Set up library later.

    Click Next.

  6. Specify the name and location settings. For more information, see Project Name and Location or Module Name and Location.

    Click Finish.

Enabling Hibernate support for an existing module

  1. In the Project tool window, right-click the necessary module and select Add Framework Support.
  2. In the left-hand pane of the Add Frameworks Support dialog that opens, select the Hibernate check box.
  3. If necessary, select to create a configuration file (hibernate.cfg.xml) and a main class (a class with a main() method for running your application).

    If there is a database defined in IntelliJ IDEA as a data source, you can select to import the database schema. This will result in creating the necessary persistent Java classes and metadata.

  4. Select the required library option and, if necessary, specify the associated settings. You can choose to:
    • Download Hibernate implementation files and arrange those files in a library.

      To do that, under Libraries, select Download. Optionally, click Configure to edit the library settings. (The Downloading Options dialog will open.)

    • Use a library that is already defined IntelliJ IDEA.

      To do that, click Use library and select the required library from the list. Optionally, click Configure to edit the library settings. (The Edit Library dialog will open.)

    • Create a new library using the appropriate JAR files available on your computer.

      To do that, click Use library and then click Create. Select the required JAR files in the dialog that opens. (For multiple selection, keep the Ctrl key pressed.) Optionally, click Configure to edit the library settings. (The Create Library dialog will open.)

    • Postpone setting up the library until a later time. In this case, select Set up library later.
  5. Click OK.

See Also

Last modified: 12 November 2014
comments powered by Disqus