Today I faced an interesting issue. I\'ve been having an inheritance hierarchy with Hibernate JPA, with SINGLE_TABLE
strategy. Later, I added a superclass to th
Well, if you read the "Inheritance" chapter of Hibernate documentation a little further :-) you'll see that the example given for mixing table-per-hierarchy and table-per-subclass strategies is in reality nothing more than table-per-hierarchy with secondary tables thrown in:
...
...
...
You can do the same using @SecondaryTable annotation:
@Entity
@Inheritance(strategy=InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name="PAYMENT_TYPE")
@DiscriminatorValue("PAYMENT")
public class Payment { ... }
@Entity
@DiscriminatorValue("CREDIT")
@SecondaryTable(name="CREDIT_PAYMENT", pkJoinColumns={
@PrimaryKeyJoinColumn(name="payment_id", referencedColumnName="id")
)
public class CreditCardPayment extends Payment { ... }
@Entity
@DiscriminatorValue("CASH")
public class CashPayment extends Payment { ... }