I have a some JPA entities that inherit from one another and uses discriminator to determine what class to be created (untested as of yet).
@Entity(name="switches")
@DiscriminatorColumn(name="type")
@DiscriminatorValue(value="500")
public class DmsSwitch extends Switch implements Serializable {}
@MappedSuperclass
public abstract class Switch implements ISwitch {}
@Entity(name="switch_accounts")
public class SwitchAccounts implements Serializable {
@ManyToOne()
@JoinColumn(name="switch_id")
DmsSwitch _switch;
}
So in the SwitchAccounts class I would like to use the base class Switch because I don't know which object will be created until runtime. How can I achieve this?