By putting @MapsId("clubId")
on the association, you’re saying ‘clubId
does not provide its own mapping. Instead, the mapping on this property here should be used to map the clubId
property’.
This means that when persisting the entity, Eclipselink will use Team.club
‘s id to populate the club_id
join column, and then, it will use the value of that join column, to populate the Java property Team.embeddedId.clubId
, whenever the entity is fetched/refreshed. Whatever mapping you put on Team.embeddedId.clubId
will be ignored.
The error comes from the fact that Eclipselink does not consider club_id
to be mapped twice. Instead, only the mapping on Team.club
is taken into account. Being the only mapping for a primary key property, it may not be insertable = false, updatable = false
.
The solution is simple:
- If you want
Team.club
to control the value of theclub_id
column, drop theinsertable = false, updatable = false
- Conversely, if you want
Team.embeddedId.clubId
to controlclub_id
, drop@MapsId
altogether
CLICK HERE to find out more related problems solutions.