Enable Hibernate
Make sure the Hibernate plugin is enabled
In the Settings / Preferences dialog Ctrl+Alt+S, select Plugins.
Type
Hibernate
in the search box to locate the necessary plugin in the list.If the checkbox next to Hibernate is not selected, select it to enable the plugin.
Click OK. If suggested, restart IntelliJ IDEA.
Enable Hibernate support for a project or module
Launch IntelliJ IDEA.
If the Welcome screen opens, click Create New Project.
Otherwise, from the main menu, select Module.
orSelect Java or Java Enterprise from the list on the left.
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.
(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.
Under Additional Libraries and Frameworks, select the Hibernate checkbox.
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).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.
Select the required library option and click Next.
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
In the Project tool window, right-click the necessary module and select Add Frameworks Support.
In the dialog that opens, select the Hibernate checkbox.
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).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.
Select the required library option and click OK.
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.