3.7.3.5. Persistent Map Fields

JPA has limited support for maps. If you extend JPA’s standard map support to encompass new mappings, use the org.apache.openjpa.persistence.PersistentMap metadata annotation to represent your custom persistent map fields. It has the following properties:

  • Class keyType: The class of the map keys. This information is usually taken from the parameterized map key type. You must supply it explicitly, however, if your field isn’t a parameterized type.

  • Class elementType: The class of the map values. This information is usually taken from the parameterized map value type. You must supply it explicitly, however, if your field isn’t a parameterized type.

  • FetchType fetch: Whether to load the collection eagerly or lazily. Corresponds exactly to the same-named property of standard JPA annotations such as Basic. Defaults to FetchType.LAZY.

  • CascadeType[] keyCascade: Array of enum values defining cascade behavior for the map keys. Corresponds exactly to the cascade property of standard JPA annotations such as ManyToOne. Defaults to empty array.

  • CascadeType[] elementCascade: Array of enum values defining cascade behavior for the map values. Corresponds exactly to the cascade property of standard JPA annotations such as ManyToOne. Defaults to empty array.

  • boolean keyEmbedded: Set this property to true if the map keys are stored as embedded objects.

  • boolean elementEmbedded: Set this property to true if the map values are stored as embedded objects.