Hibernate session factory can be created in two ways:
- In the Project tool window, right-click the desired module, and choose Module Settings on the context menu.
- Under the desired module node, click its Hibernate facet.
- In the Descriptors section, click (Alt+InsertAlt+InsertAlt+InsertAlt+InsertAlt+InsertAlt+InsertAlt+InsertAlt+Insert or Ctrl+NAlt+InsertCommand N or Control EnterControl N or Control EnterCommand N or Control Enter) and select . Specify the deployment descriptor location, and click Apply. A session factory is added to the list of data source mappings.
In the Data Sources Mapping section,
specify the data source for the new
Hibernate session factory. To do that, select the entry for the new session factory column,
the corresponding data source in the Data Source column, and select
one from the list
of configured data sources.
- Open the Hibernate configuration file in the editor, and configure connection properties, and the other properties as required.
- Open Persistence tool window.
- Under the Hibernate Facets node, right-click the desired module,
on the context menu.
- In the dialog that opens, select the desired Hibernate configuration file. If a file doesn't exist, click , and specify the configuration file name and the target package. The source code of the new Hibernate configuration file opens in a separate tab in the editor, and in the Persistence tool window two nodes are created: for the configuration file, and for the corresponding session factory.
- Open the Hibernate configuration file in the editor, and configure connection properties, and the other properties as required. Note syntax highlighting, validation of references, and code completion provided by IntelliJ IDEA.