Hibernate is an object-relational mapping framework that implements the Jakarta Persistence (JPA) specification.
IntelliJ IDEA provides the following:
Coding assistance specific to Hibernate.
A dedicated facet for managing the Hibernate configuration hibernate.cfg.xml.
Additions to the Persistence tool window for managing your Hibernate items, creating configuration files and persistent classes, navigating to related source code in the editor, opening diagrams and consoles, and more.
Entity-relationship (ER) diagrams that you can access from the Persistence tool window.
An ability to generate managed entity classes and object-relational mappings for them by importing a database schema or an EJB deployment descriptor file ejb-jar.xml.
The Hibernate console for writing and running HQL queries, and analyzing the query results.
Create a new Java Enterprise project with Hibernate
Click New Project on the Welcome screen or select .
From the Generators list, select Jakarta EE.
Name the new project, select a build tool, a language you want to use, and select the Web application project template.
From the JDK 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.
On the next step of the wizard, select the Java Enterprise version to be supported.
From the Dependencies list, select the Persistence (JPA) specification and Hibernate as the implementation.
For more information on how to create a Java Enterprise project, refer to Tutorial: Your first Java EE application.
IntelliJ IDEA creates the default project structure with the JPA facet and all the necessary libraries as external dependencies, such as
javax.persistence for the JPA specification and
org.hibernate for the Hibernate framework. If you specified an application server, IntelliJ IDEA will also create a run configuration to start the server, build and deploy the artifact.
Enable Hibernate support for an existing project
Open the build file in the editor (pom.xml or build.gradle depending on the build tool that you use in your project).
Add the following dependency, but make sure to change the version according to your project's requirements:<dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-core</artifactId> <version>5.6.0.Final</version> </dependency>implementation('org.hibernate:hibernate-core:5.6.1.Final')
Press Ctrl+Shift+O to import the changes.
For more information on how to work with build tools, see to Maven or Gradle.