How to apply unique constraints using annotation

前端 未结 3 1671
别那么骄傲
别那么骄傲 2021-02-12 22:41
@Column(name = \"userId\")
    @UniqueConstraint
    private Integer userId;

I am using these annotation for entering data into database table. i want

3条回答
  •  执笔经年
    2021-02-12 23:04

    And this is the explanation of the Hibernate doc version 3.5 for @UniqueConstraint definition.

     @Entity
        @Table(name="tbl_sky",uniqueConstraints = {@UniqueConstraint(columnNames={"month", "day"})})
        public class Sky implements Serializable {
           ...
        }
    

    and this is for Hibernate 4.3 example for @UniqueConstraint

提交回复
热议问题