Hibernate mapping a composite key with null values

后端 未结 6 2054
栀梦
栀梦 2020-12-09 09:27

With Hibernate, can you create a composite ID where one of the columns you are mapping to the ID can have null values?

This is to deal with a legacy table that has a

6条回答
  •  借酒劲吻你
    2020-12-09 10:01

    For composite keys (assumed that database allows nulls in PKs) you can have maximum number_of_cols^2 - 1 entries containing nulls, (for example for composite key of 2 columns you can have 3 rows having in their primary key null, the fourth is the PK without nulls).

提交回复
热议问题