JPA - @Column (unique=true) - What is really point of having 'unique' attribute?

后端 未结 3 1996
别那么骄傲
别那么骄傲 2020-12-29 01:46

Suppose I am having \'subject\' table

CREATE TABLE subject (id int PRIMARY KEY, name VARCHAR(255) **UNIQUE**)

and associated Mapped Object,

3条回答
  •  梦谈多话
    2020-12-29 02:38

    unique=true in @Column annotation will be used only in DDL generation, it doesn't have any impact during runtime. The actual uniqueness checks happens in the database.

提交回复
热议问题