Joined subclasses

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

Figure 1053. Joined subclass mapping.

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 ❸.