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 ( or or or or ) 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, double-click
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, and choose
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.