休眠注释中的@UniqueConstraint和@Column(unique = true)
2022-08-31 08:50:46
@UniqueConstraint和@Column(unique = true)有什么区别?
例如:
@Table(
name = "product_serial_group_mask",
uniqueConstraints = {@UniqueConstraint(columnNames = {"mask", "group"})}
)
和
@Column(unique = true)
@ManyToOne(optional = false, fetch = FetchType.EAGER)
private ProductSerialMask mask;
@Column(unique = true)
@ManyToOne(optional = false, fetch = FetchType.EAGER)
private Group group;