Hello forum,
As a common issue, my domain model contains some enumerations and there are several ways to persist an enumeration to a database.
Now, that I've started a new project (and a database schema) from scratch, I've asked myself, what is the most elegant / handy / best practise approach to persist an enumeration (with all it's literals) to a database?
To use the common ColorTypeEnumeration as example:
Code:
public class car {
public ColorTypeEnumeration color;
}
public enum ColorTypeEnumeration {
BLACK,
RED;
}
What's the best practise to define a Hibernate Mapping (hbm-file) to persit the enumeration and all it's literals (BLACK, RED) into the database?
I've read the "UserType for persisting an Enum" docs (
http://www.hibernate.org/265.html), but does this solution persits the literals of the enumeration?