Null list returned from hibernate query with embedded id

前端 未结 4 1271
独厮守ぢ
独厮守ぢ 2020-12-31 12:52

I have an entity with an embedded key. The entity has only the key as a field and the key has 7 fields, some of which can be null.

When I run the following query:

4条回答
  •  清酒与你
    2020-12-31 13:24

    As user405935 said, it is not a good idea to have nullable columns as a part of your composite key.

    I was in the same situation as yours and the problem was that the entries from the table had NULL values on the columns that took part from my composite key, so it couldn't create my embedded key at runtime.

    Solutions:

    1. make those columns non-nullable, or
    2. add a new column used as primary key, or
    3. find another embedded key using only non-nullable columns

提交回复
热议问题