Open
Description
Hibernate allows support for inheritance making it possible to things like this:
@Inheritance(strategy=InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name="content_type", discriminatorType=DiscriminatorType.STRING)
@Table("site_content")
public class SiteContent {
@Id
@Generated
public uint id;
@Column("title") @NotNull
public string title;
@Column("content") @NotNull
public string content; // LONGTEXT
}
@Entity
@DiscriminatorValue("wikipage")
public class WikiPage : SiteContent {}
@Entity
@DiscriminatorValue("blogpost")
public class BlogPost : SiteContent {}
More information on @Inheritance
and the related annotations can be found here.