IntelliJ IDEA 2020.2 Help

Enable JPA support

Make sure the plugin is enabled

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

  2. On the Plugins page, type JPA in the search box. Locate the plugin in the list.

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

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

    Making sure JPA plugin is enabled

Enable JPA 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 JavaEE Persistence checkbox.

  6. Select the version of persistence.xml (JPA configuration file) that you want to create.

  7. If necessary, select the Java persistence (implementation) provider.

    This setting only affects the provider element in persistence.xml.

  8. 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 JPA entity classes and object/relational mappings for them.

  9. Select the required library option and click Next.

    Creating a new JPA project

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

Enable JPA support for an existing module

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

  2. In the left-hand pane of the Add Frameworks Support dialog that opens, select the JavaEE Persistence checkbox.

  3. Select the version of persistence.xml (JPA configuration file) that you want to create.

  4. If necessary, select the Java persistence (implementation) provider.

    This setting only affects the provider element in persistence.xml.

  5. 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 JPA entity classes and object/relational mappings for them.

  6. Select the required library option and click OK.

    Adding JPA support to a module

Once the facet is added, from the main menu, select View | Tool Windows | Persistence.

Last modified: 23 June 2020