Multiple unique constraints in JPA

The @Table‘s attribute uniqueConstraints actually accepts an array of these. Your example is just a shorthand for an array with a single element. Otherewise it would look like: @Table(name=”person”, uniqueConstraints={ @UniqueConstraint(columnNames={“code”, “uid”}), @UniqueConstraint(columnNames={“anotherField”, “uid”}) }) Whenever the unique constraint is based only on one field, you can use @Column(unique=true) on that column.

Specifying an Index (Non-Unique Key) Using JPA

With JPA 2.1 you should be able to do it. import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.Index; import javax.persistence.Table; @Entity @Table(name = “region”, indexes = {@Index(name = “my_index_name”, columnList=”iso_code”, unique = true), @Index(name = “my_index_name2″, columnList=”name”, unique = false)}) public class Region{ @Column(name = “iso_code”, nullable = false) private String isoCode; @Column(name = “name”, nullable = … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)