There is quite much nothing to configure, just creating relationship to Payment, for example:
@OneToOne private Payment payment;
and then assigning value to it and persisting them.
No additional columns are used to find out type of the Payment. To determine type of the Payment Hibernate
- Makes union of
- results of query to CashPayment
- results of query to CreditCardPayment table.
- Those select statements contain additional item in select list that denotes type.
- Outer select fetches values from nested query (result of union). Additional attribute determines which concrete class will be used when creating instances of Payment.