Introduction to the hibernate collection Interface
In Java Domain Models, set attributes are always the same
Private <inteface> ATTR = new <implementaction> (); // initialize the object as early as possible to avoid uninitialized sets.
...
// Getter and setter
<Set>
Semantics: unordered, repeat is not allowed, and the sequence of elements is not saved.
Ing interface: Java. util. set or Java. util. sortedset
Implementation class: Java. util. hashset or Java. util. treeset
Note: set corresponds to hashset; sortedset corresponds to treeset. sortedset can be used to set a comparator or for natural sorting in memory.
<List>
Semantics: ordered and repeatable storage locations with additional indexes
Ing interface: Java. util. lits
Implementation class: Java. util. arraylist
<Big>
Semantics: unordered, repeatable, and element order not saved
Ing interface: Java. util. Collection
Implementation class: any class that can be used to implement the collection interface. java. util. arraylist is generally used (although list has an index, if it is big, the index will not be saved)
<Idbig>
Unlike big, it provides an additional primary key to distinguish distinct elements.
<Map>
Semantics: stores key/value pairs. The key cannot be repeated without saving the element sequence.
Ing interface: Java. util. map or Java. util. sortedmap
Implementation class: Java. util. hashmap or Java. util. treemap
Note: Map corresponds to hashmap; sortedmap corresponds to treemap. sortedmap can be used to set the comparator or to use the natural sequence in the memory.
<Primitive-array> <array>
Rarely used in Domain Models
About JPA
JPA does not list all of these options. The available standard set attributes are set, list, collection, and map.
About Expansion
If you cannot find the collection interface or implementation you need in the previous collection, you can extend the persistentcollection. Generally, you can extend one of the existing persistentset, persistentbag, and persistentlist classes.