JPA Collection has unwanted unique constraint in mapping table

As said for example in JavaDocs, @ElementCollection is used to map collection of basic types or embeddables. Alert is an entity and consequently List<Alert> is not collection of Basic types or embeddables.

Because unique constraint that consists of scanid and alert_id is preferred, I assume that relationship between Scan and Alert does have many-to-many nature. That can be achieved as follows:

@ManyToMany
@JoinTable(name = "scanalerts",  schema = RfidConstants.SCHEMA,
  joinColumns = @JoinColumn(name = "scanid"),
  inverseJoinColumns = @JoinColumn(name = "alert_id")
)
private List<Alert> alerts;

Primary key of table contains both columns and that's why using @UniqueConstraint is not needed.