I am trying to introduce a multi-key constraint for a JPA-mapped object:
public class InventoryItem { @Id private Long id; @Version private Long version; @ManyToOne @JoinColumn("productId") private Product product; @Column(nullable=false); private long serial; }
In principle, a (commodity, consecutive) pair should be unique, but I found a way to say that the serial number should be unique. This is obviously not a good idea, as different products may have the same serial numbers.
Is there a way to generate this restriction via JPA or am I forced to manually create it in DB?
java mapping jpa
plouh May 05 '10 at 10:46 a.m. 2010-05-05 10:46
source share