Currently I have Enums let’s say
enum Category {
A, B
}
and
enum Type {
TYPE1(Category.A), TYPE2(Category.B), TYPE3(Category.A)
private Category cat;
private Type(Category cat) {
this.cat = cat;
}
}
I am using EnumUserType for these enums in hibernate. I would like to change it so that the mapping of Type to category would be defined in database rather than explicitly in the code, what would be the easiest way to do that?
I would add column to table defining TYPE in database with foreign key referencing CATEGORY, what I would like to know is the hibernate mapping.
(I am aware that this may seem like a stupid question)
You would need to create an Entity for at least Type (so no enum Type anymore).
Then store the enum Category as a field in Type or also create an Entity for this.