I am trying to introduce a multi-key constraint on a JPA-mapped entity:
public class InventoryItem {
@Id
private Long id;
@Version
private
As already answered, multi-column index can be added using @Table
annotation. However, columnNames
needs to be the name of actual DB columns, not the class attribute. So, if the column is like the following:
@Column(name="product_id")
Long productId;
Then the @Table
annotation should be like the following
@Table(uniqueConstraints=
@UniqueConstraint(columnNames = {"product_id", "serial"})