I have composite primary key where one of the keys is null. What annotations must be present in the entity so that I can get data using JPA of this kind:
ID_FIRST_KEY |ID_SECOND_KEY |DATA
-------------------------------------
1 |100 |data1
1 |200 |data2
1 |null |data3
2 |100 |data4
......................................
I tried to use IdClass Annotation and EmbeddedId Annotation but I get exception:
Exception Description: The primary key read from the row [ArrayRecord(
DATA.ID_FIRST_KEY => 1
DATA.ID_SECOND_KEY => null
DATA.DATA => data3)] during the execution of the query was detected to be null. Primary keys must not contain null.
The data was used for example, but similar data is used in a real project, so there is no way to replace null with a value.