Hibernate: Single table inheritance annotations
July 19th, 2009 by jeremychone@Entity
@Table(name = "employee")
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name = "ctype", discriminatorType = DiscriminatorType.CHAR)
@DiscriminatorValue("e")
@ForceDiscriminator //optional
public class Employee{
...
}
And the subclass would be like
@Entity
@DiscriminatorValue("m")
public class Manager extends Employee{
....
}
August 24th, 2010 at 8:54 am
Annotate the “ctype” field in the superclass with: @Column(insertable=false, updatable=false) to fix this problem.