How to create unique constraint for 2 columns in JDL-Studio?

前端 未结 3 428
走了就别回头了
走了就别回头了 2021-02-05 22:07

I have following entity configuration:

entity AirplaneModelSeat { 
    id Long, 
    seatNo String required 
}
relationship ManyToOne   { 
    AirplaneModelSeat{         


        
3条回答
  •  名媛妹妹
    2021-02-05 22:48

    In addition to the Liquibase configuration in David's answer I suggest you also add the relevant JPA annotations to your Entity. Here is an example how:

    @Table(name = "table_name",
        uniqueConstraints = {@UniqueConstraint(columnNames = {"field_1", "field_2"})})
    

    Note that since in this case @UniqueConstraint is applied at Entity (i.e. Table) level, you can combine multiple fields into a composite unique key.

提交回复
热议问题