0

I have the TranslationBase base abstract class, and tow subclasses[entities] : CountryTranslation and RegionTranslation as shown below :

TranslationBase:

@MappedSuperclass
@IdClass(TranslationBasePK.class)
public abstract class TranslationBase<T> implements Serializable {

    @Id
    @ManyToOne
    @JoinColumn(name = "id")
    private T ownerEntity;

    @Id
    @JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
    @Column(name = "language_id")
    private Long languageId;

    private String name;
}

CountryTranslation :

@Entity
@Table(name = "country_translation")
public class CountryTranslation extends TranslationBase<Country> {
}

RegionTranslation :

@Entity
@Table(name = "region_translation")
public class RegionTranslation extends TranslationBase<Region> {
}

And TranslationBasePK :

public class TranslationBasePK implements Serializable {

    private Long ownerEntity;

    private Long languageId;
}

On DB i found the id column in CountryTranslation and RegionTranslation tables reference to Country table id !!

I expect CountryTranslation to reference the id of Country and RegionTranslation to reference the id of Region class.

Note : Country and Region have @Id feild named id;

0 Answers0