Hi all,

Is it possible to specify a unique constraint over multiple columns within a container table? I know a unique index on a single column is supported via @ElementIndex. Here's a small example:

@Entity public class Person {
  @Id private long id;

  @PersistentCollection
  @ContainerTable(
    name = "PersonAliases",
    joinColumns = @XJoinColumn(name = "person_id")
  )
  @ElementColumn(name = "value")
  private Set<String> aliases;
  // TODO uniqueConstraint = {"person_id", "value"}
}

The DDL generated with OpenJPA 1.2.0 and MySQL DBDictionary is

CREATE TABLE Person (id BIGINT NOT NULL, PRIMARY KEY (id)) TYPE = innodb
CREATE TABLE PersonAliases (person_id BIGINT, value VARCHAR(255)) TYPE = innodb
CREATE INDEX I_PRSNLSS_PERSON_ID ON PersonAliases (person_id)

The same question seems to apply to join tables.

-Andy

Reply via email to