In this video I will show you how a Java enum type is persisted into a database using a demo project.
An enum type is mapped to a database via the @javax.persistence.Enumerated annotation.
There are two strategies to store enum values in the database -
@Enumerated(EnumType.ORDINAL) ? Store the enum values according the ordinal position
(i.e. 0 , 1, 2 … ) of enum value.
@Enumerated(EnumType.STRING) ? Store the enum values according to the name of enum value.
The default is EnumType.ORDINAL.
Below is the GitHub link to download source:
[ Ссылка ]
Ещё видео!