It\'s possible to define enumerations in JPA using either
@Enumerated(EnumType.ORDINAL)
or
@Enumerated(EnumType.STRING)
It's likely that ORDINAL
is more efficient, but that's minor. There are a few downsides to ORDINAL
:
With STRING
you can't rename your enums.
Pick one of them and use it throughout the whole application - be consistent.
If your database is going to be used by other clients/languages - use STRING
, it's more readable.