How to apply constraints like unique, not null ...etc in collection attribute of a entity.
Example :
@Entity @Table(name = "agent") public class Agent implements Serializable { @Id @GeneratedValue(strategy = GenerationType.AUTO) private Long Id; private List<String> PhoneNumbers; public Agent() { } public Long getId() { return Id; } public List<String> getPhoneNumbers() { return PhoneNumbers; } public void setPhoneNumbers(List<String> PhoneNumbers) { this.PhoneNumbers = PhoneNumbers; } }
in above example i wants to implement unique and notnull constraints on PhoneNumbers, means PhoneNumbers must not be duplicate or null How to do this?
Thanks