IntelliJ IDEA 2016.2 Help

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.

You can create Hibernate elements manually, by means of creating annotated Java classes, or use the context menu of 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

  1. In the Persistence tool window, right-click the desired session factory, and choose element type from the New context menu.


  2. 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.
  3. Further, to add members, right-click the desired element, and choose member type on the context menu.
  4. In the dialog box that opens, specify the member name and type. Where necessary, specify the target metadata files.

See Also

Last modified: 3 June 2016