SQL JPA - Multiple columns as primary key

前端 未结 5 1380
猫巷女王i
猫巷女王i 2020-12-23 09:51

If i want severeal Column to make up an ID.

SQL example :

CONSTRAINT [PK_NAME] PRIMARY KEY ([Column1],[Column2],[Column3])

How can

5条回答
  •  伪装坚强ぢ
    2020-12-23 10:19

    Be aware that the hibernate Entity-Class-to-SQL-DDL-Script generator will sort all the fields, and irrespective of the order in which it appears in the definitions, will create the table definition and the index / constraint definitions in this sorted order of the fields.

    While the order of appearance of the fields in the table definition may not matter much, the order of fields in a composite index definitely do. So your key-fields must be named so that when sorted by their names they are in the order you desire for the index).

提交回复
热议问题