Unique values for two columns in Doctrine
问题 I have entity called Dimension. It has three attributes - ID, width and height. ID is primary key. In the table, the dimension should be unique so there has to be only one record with given dimension (for example 40x30). What constraints I need to set? Is uniqueConstraints={@UniqueConstraint(name="dimension", columns={"width", "height"})} correct? 回答1: From the documentation, @UniqueConstraint annotation is used inside the @Table annotation on the entity-class level. It allows to hint the