@MappedSuperclass
public abstract class AbstractEntity<ID> {
public abstract ID getId();
}
@Entity
@Table(name = "USERS")
public class User extends AbstractEntity<Long> implements WithTranslationKey {
@Id
@GeneratedValue
private Long id;
private String name;
}
@MappedSuperclass
public abstract class AbstractTranslationEntity<T extends AbstractEntity<Long> & WithTranslationKey>
extends AbstractEntity<Long> {
@Id
@GeneratedValue
private Long id;
@JoinColumn(name = "CLASSIFIER_ID", nullable = false)
@ManyToOne(fetch = FetchType.LAZY, optional = false)
private T classifier;
@Column(name = "LOCALE_CODE", length = 15, nullable = false)
private String localeCode;
}
@Entity
@Table(name = "USER_TRANSLATION")
public class UserTranslation extends AbstractTranslationEntity<User> {
private String translation;
}