@Column(name = "userId") @UniqueConstraint private Integer userId;
我正在使用这些注释将数据输入数据库表。我想使userId字段唯一。但是当我这样做时,它向我显示错误@UniqueConstraints is disallowed for this location.
@UniqueConstraints is disallowed for this location.
@Column(name = "userId",unique=true)
或者,如果它是数据库生成的ID,您也可以执行此操作
@Id @GeneratedValue(strategy=GenerationType.AUTO) private Integer id;