3.7.3.4. Persistent Collection Fields
JPA standardizes support for collections of entities with the
OneToMany and ManyToMany persistence strategies.
OpenJPA supports these strategies, and may be extended for other strategies as well.
For extended strategies, use the
org.apache.openjpa.persistence.PersistentCollection metadata annotation to represents any persistent collection field.
It has the following properties:
-
Class elementType: The class of the collection elements. This information is usually taken from the parameterized collection element 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 asBasic. Defaults toFetchType.LAZY. -
String mappedBy: Names the field in the related entity that maps this bidirectional relation. Corresponds to the same-named property of standard JPA annotations such asManyToMany. -
CascadeType[] elementCascade: Array of enum values defining cascade behavior for the collection elements. Corresponds exactly to thecascadeproperty of standard JPA annotations such asManyToMany. Defaults to empty array. -
boolean elementEmbedded: Set this property totrueif the elements are stored as embedded objects.