JPA实体继承有两个DiscriminatorColumn

时间:2015-08-14 07:30:00

标签: java hibernate jpa inheritance discriminator

我需要你的帮助。

我有JPA map所需的以下值表。

Table to map

我考虑了以下类结构。

enter image description here

班级" NotificationCustomShippingPlan"和" PreviewCustomShippingPlan"让每个人都成为DiscriminatorColumn" Type"。

但是班级" ActivResultCustomShippingPlan"和" ActivResultCustomShippingPlan"应该得到其他DiscriminatorColumn" SubType"。

我怎么能这样的地图?

我的感觉告诉我,这是不可能的。

编辑:

@Entity
@Inheritance
@DiscriminatorColumn(name = "TYPE")
@Table(name = "CC_CUSTOM_SHIPPING_PLAN")
public abstract class AbstractCustomShippingPlan {
....
....
}


@Entity
@DiscriminatorValue("NOTIFICATION")
public class NotificationCustomShippingPlan extends AbstractCustomShippingPlan



@Entity
@DiscriminatorValue("PREVIEW")
public class PreviewCustomShippingPlan extends AbstractCustomShippingPlan


@Entity
@DiscriminatorValue("RESULTS")
@DiscriminatorColumn(name = "SUBTYPE")
public abstract class ResultCustomShippingPlan extends AbstractCustomShippingPlan {

    @Enumerated(EnumType.STRING)
    @Column(name = "CC_CSP_SUBTYPE")
    private ServiceType.Subtype subtype;

}


@Entity
@DiscriminatorValue("ACTIVE")
public class ActivResultCustomShippingPlan extends ResultCustomShippingPlan{
    .....
}



@Entity
@DiscriminatorValue("REPORTED")
public class ReportedResultCustomShippingPlan extends ResultCustomShippingPlan {
....

}

0 个答案:

没有答案