7. Possible Variations and Extensions

7.1. Ordered-Set-Valued Attributes

In cases where the order of the set of values of a multi-valued attribute, such as Person::phones, is significant, e.g. because it expresses a priority ordering, the collection value of such an attribute represents an ordered set. We use List as the collection type of an ordered-set-valued attribute and apply the @OrderColumn annotation for creating a sequence number column in the table used for storing the values of the multi-valued attribute, like in the follwoing example:

@Entity @Table( name="people")
@ViewScoped @ManagedBean( name="person")
public class Person {
  ...
  @OrderColumn
  @ElementCollection 
  private List <String> phones;
  ...
}