Unique constraint not created in JPA
Posted
by homaxto
on Stack Overflow
See other posts from Stack Overflow
or by homaxto
Published on 2010-05-31T14:19:25Z
Indexed on
2010/05/31
14:23 UTC
Read the original article
Hit count: 221
I have created the following entity bean, and specified two columns as being unique. Now my problem is that the table is created without the unique constraint, and no errors in the log. Does anyone have an idea?
@Entity
@Table(name = "cm_blockList", uniqueConstraints = @UniqueConstraint(columnNames = {"terminal", "blockType"}))
public class BlockList {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private int id;
@ManyToOne(cascade = CascadeType.PERSIST)
@JoinColumn(name="terminal")
private Terminal terminal;
@Enumerated(EnumType.STRING)
private BlockType blockType;
private String regEx;
}
© Stack Overflow or respective owner