I understood how to use DiscriminatorColumn in Hibernate inheritance mapping, However, in my scenario, I have more complicated inheritance module, where I need to define two Discriminators. I want to use one table for the entire inheritance tree. Basically, the parent class is abastract, and it represents a person entity, then, I have two different abstract implementation of it, Wife & Husband. so basically I already need one discriminator. then for each (Wife & Husband) I have different messages that needs to be persisted, so I need no to create a discriminator for each (Wife & Husband).
I came up with this implementation, but I'm stuck, how do I continue from here ?
@Entity
@Table (name="sex")
@Inheritance (strategy=InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn (name="transaction_type", discriminatorType=DiscriminatorType.STRING)
public abstract class Person {
...
}
@Entity
@DiscriminatorValue("wife")
public class Wife extends Person {
...
}
now, how do I put a discriminatorcolumn on the Wife Class, the same as I did with the Parent ?