@Entity
class Person(
@Column(unique = true, nullable = false)
val name: String,
@GeneratedValue(strategy = GenerationType.IDENTITY)
val id: Int? = null,
)
我看到,当创建数据库时,
unique
约束将在稍后通过ALTER添加。
Hibernate: create table Person (id integer, name varchar(255) not null, primary key (id))
Hibernate: alter table Person add constraint UK_is4vd0f6kw9sw4dxyie5cy9fa unique (name)