To define how an entity class will be persisted to a data store, you have to specify the persistent fields. This can be done in one of the following ways:
- By editing the source code of an entity class
- Using the context menu of an entity
When a persistent field is added to an entity, the respective annotated properties are added to the source file of the entity class, the field is marked with a gutter icon in the editor, and the member nodes are added to the persistence unit node in the Persistence tool window , and to the ER diagram of the persistence unit.
- Open the desired entity class for editing.
- Type the desired field declaration:

- Create getter and setter methods. To do that, press ⌘N, ⌃⏎, ⌘N or ⌃⏎⌃N, ⌃⏎, ⌃N or ⌃⏎⌘N, ⌃⏎, ⌘N or ⌃⏎^ N, ⌥ Insert, ⌃N or ⌃N⌥ Insert,
and select from the suggestion list:

- Annotate the field. If the required import is missing, use the suggested quick fix:

- Open Persistence tool window.
- In the desired persistence unit, right-click persistence entity, and choose the desired persistence
field type:

The available options are:
-
Basic
- Element Collection
(a collection of embeddable objects
) -
Embedded
-
Embedded Id
-
Id
-
Version
You can invoke the same command on the context menu of an entity in the ER diagram.
-
Basic
- In the dialog box that opens, specify the field name and type, and click OK.