Open reitzmichnicht opened 6 years ago
While this optimisation is safe to do at runtime, I'm rather reserved to extend this optimisation to the DB schema. For this reason, I prefer to persist enums by their String value rather than their ordinal, or even better, the PostgreSQLEnumType provided in this repository.
EnumSet
is a collection of Enum identifiers, so I think the Type is going to be useful since the default Enum can only store a single Enum value, while this one will encode multiple Enum values (e.g. toppings on a pizza).
I definitely see how it would be useful, but it just seems to dangerous to me for someone to mess up the ordinals 😄 So I personally wouldn't use it. I'd rather see a native array version of the existing enum type. Just my two cents!
I would stay away from adding EnumSet as a bitfield. The values of the enum chan and will change over time, but we don't want the mapping to change. I agree with @jwgmeligmeyling in that they should be represented as Strings.
Found this in a Google search and saw that it has some recent activity - thought I'd add my thoughts!
See also Issue #126
Hi
Java recommends using EnumSets as bitfield or flags enums where every enum entry has its dedicated bit. Can you add an example how an EnumSet inside an entity can be mapped to an integer column instead of having a 1:n relation?
Kind regards, Michael