Joined subclasses

The basic idea is to generate a normalized schema implementing inheritance relationships by foreign keys:

Figure 946. Joined subclass mapping.

Todo: Ref/Fig/billingMapJoined.fig


The inheritance strategy of joined subclasses ❶ is being defined in the abstract base class inherit.joined.v1.BillingDetails:

package inherit.joined.v1;
	...
	@Entity
	@Inheritance(strategy=InheritanceType.JOINED) ❶
	public abstract class BillingDetails { ... }

The derived classes need to provide an implementation hint in order to identify the required foreign key ❶ to the parent class inherit.joined.v1.BillingDetails:

package inherit.joined.v1;
	...
	@Entity
	@PrimaryKeyJoinColumn(name="parent" ❶, referencedColumnName="id")
	public class CreditCard extends BillingDetails {

	int cardType;
	@Column(nullable=false) ❷
	public int getCardType() {return cardType;}
	public void setCardType(int cardType) {this.cardType = cardType;}
	
	Date expiration;
	@Column(nullable=false) ❸
	public Date getExpiration() {return expiration;}
	public void setExpiration(Date expiration) {this.expiration = expiration;}
	...
	}

Notice the ability to exclude null values in ❷ and ❸.