Creating Hibernate Elements in a Session Factory
Once a session factory is created, the next step is to populate it with entities, embeddables, etc. Creating an element in a session factory results in creating the corresponding Java class, entries in the metadata files, and adding a node to the session factory in the Persistence tool window.
When you use the context menu commands, IntelliJ IDEA takes care of creating classes and members, providing annotations and adding the corresponding entries to the descriptor files.
When you create the Hibernate elements and members manually, it is the developer's responsibility to create the necessary declarations, annotations, and accessor methods. IntelliJ IDEA provides extensive coding assistance in the Java classes and metadata files.
To create a Hibernate element using the context menu of the Persistence tool window
- In the Persistence tool window, right-click the desired session factory,
and choose element type from the context menu.
- In the dialog box that opens, specify class name and location, and click OK. For the entity listeners, specify the listener methods to be implemented, and the entity listener bindings.
- Further, to add members, right-click the desired element, and choose member type on the context menu.
- In the dialog box that opens, specify the member name and type. Where necessary, specify the target metadata files.