TableA has a 3 column composite primary key, TableB has a 2 column composite key primary key (these 2 columns are in TableA) and TableC
has a single column primary key but has a composite foreign key from TableB.
This is an inherited table structure which I cannot change.
TableA 1:1 TableB
TableB M:1 TableA
TableB 1:M TableC
TableC M:1 TableB
UNB_NETWORK_CLINIC_PROVIDER - TABLE A
NETWORK_NO (PK)
CLINIC_NO (PK)
PROVIDER_NO (PK)
DELTA_BEGIN_DATE
DELTA_END_DATE
UNB_CLINIC_PROVIDER - TABLE B
CLINIC_NO (PK)
PROVIDER_NO (PK)
DELTA_BEGIN_DATE
DELTA_END_DATE
UNB_FOCUS_REVIEW - TABLE C
FOCUS_REVIEW_NO (PK)
PROVIDER_NO(FK)
CLINIC_NO(FK)
PROC_NO_FROM
PROC_NO_TO
I have used OneToMany JPA annotation to model the mapping between TableB and TableC using the composite key in the mappedBy attribute.
Please see code below in namely UnbClinicProv.java and UnbFocusReview.java. This worked when the composite key of TableB was a foreign key in TableC.
I tried (the same thing I thought) for the OneToOne mapping in UnbNetworkClinicProvider.java but this gives the error below.
Is it possible to model the OneToOne mapping between TableA and TableB using JPA annotations when the composite key of TableB is not a
full foriegn key in TableA?
If yes how?
Please see below for the tables, code snippets and error I get;
Any help/comments appreciated.
Error:
UnbClinicProv.java
UnbFocusReview.java
UnbNetworkClinicProvider.java
NetworkClinicProviderCompoundKey.java
ClinicProvCompoundKey.java