JPA::Multiple inheritance
I have the following structure:
@Entity
@Table(name = "Document")
@Inheritance(strategy = InheritanceType.JOINED)
@DiscriminatorColumn(name = "docType")
@DiscriminatorValue("DOC")
public class Document implements Serializable {
@Id
@Column(name = "id")
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
….
}
@Entity @Inheritance @DiscriminatorValue("CONTRACT")
@Table(name = "Contract")
public class Contract extends Document {
}
Now I need to implement another module with similar structure:
@Entity
@Table(name = "Transaction")
@Inheritance(strategy = InheritanceType.J开发者_JS百科OINED)
@DiscriminatorColumn(name = "transType")
@DiscriminatorValue("TR")
public class Transaction implements Serializable {
@Id
@Column(name = "id")
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
….
}
@Entity @Inheritance @DiscriminatorValue("SPD")
@Table(name = "Spd")
public class SPD extends Transaction {
}
@Entity @Inheritance @DiscriminatorValue("TD")
@Table(name = "TD")
public class TD extends Transaction {
}
But, suddenly it turned out that TD should be also Document! Theoretically, TD should also extend Document But what to do with ids? Have no clue how to manage them…
Thanks in advance
精彩评论