I’m getting the issue with @AssociationOverride combined with @OneToMany with mappedBy. So I have next hierarchy and classes:
@Entity
public class Link {
@JoinColumn(name = "from_event_id")
private Event fromEvent;
@JoinColumn(name = "from_super_event_id")
private SuperEvent fromSuperEvent;
@JoinColumn(name = "from_extra_event_id")
private ExtraEvent fromExtraEvent;
}
@Entity
public class Event {
@OneToMany(mappedBy = "fromEvent", fetch = FetchType.LAZY)
private List<Link> linkLeft = new ArrayList<>();
}
@Entity
public class SuperEvent extends Event {
@OneToMany(mappedBy = "fromSuperEvent", fetch = FetchType.LAZY)
private List<Link> linkLeft = new ArrayList<>();
}
@Entity
public class ExtraEvent extends SuperEvent {
@OneToMany(mappedBy = "fromExtraEvent", fetch = FetchType.LAZY)
private List<Link> linkLeft = new ArrayList<>();
}
I need every of Event, SuperEvent and ExtraEvent pull their own linkLeft. But for both child classes mapping from basic class “fromEvent” always used.
I tried to declare @AssociationOverride for SuperEvent and ExtraEvent but app don’t want to start and raising the error: Property linksLeft is inherited from entity …Event and may not be overridden using ‘@AssociationOverride’ in entity subclass
Please advice any workaround for this. It’s obvious workaround to rename properties, but app infrastructure tied to this naming so it’s not a proper way so far.
Thank you