openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andy Schlaikjer <ha...@cs.cmu.edu>
Subject how to specify index / unique constraint on multiple columns of a container table?
Date Fri, 10 Oct 2008 19:07:36 GMT
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


Mime
View raw message