@UniqueConstraint and @Column(unique = true) in hibernate annotation

前端 未结 4 1830
别跟我提以往
别跟我提以往 2020-12-07 10:04

What is difference between @UniqueConstraint and @Column(unique = true)?

For example:

@Table(
   name = \"product_s         


        
4条回答
  •  感情败类
    2020-12-07 10:44

    From the Java EE documentation:

    public abstract boolean unique
    

    (Optional) Whether the property is a unique key. This is a shortcut for the UniqueConstraint annotation at the table level and is useful for when the unique key constraint is only a single field. This constraint applies in addition to any constraint entailed by primary key mapping and to constraints specified at the table level.

    See doc

提交回复
热议问题