|
You can set a discriminator in your mapping file, related to a column in the table.
That let's you to create a superclass, and then, creates many classes (each one which a value of the discriminator column) that extends the superclass. Hibernate will manage the differents subclasses instances depending the value of the discriminator column.
For example, if you choose the column "id_type" as the discriminator column in a table Documents corresponding with class Document, and subclass Note (extending Document) when the discriminator is equals to 1, when you try to load a Document with id_type = 1, hibernate will return a Note instance. And when you try to save a Note instance, hibernate will save a register in the Documents table with id_type = 1. Each subclass of Document can have its owns properties.
For more information, read hibernate documentation.
|