Zaza223
Zaza223

Reputation: 1

Is there a way to create new table for enum type in spring boot jpa?

Is there any way to define an enum in spring boot such that a new table for that enum will be created and also they will be mapped to another entities that use the enum?

Upvotes: 0

Views: 944

Answers (1)

Amir Parvaneh
Amir Parvaneh

Reputation: 31

since we added the annotation @Enumerated(EnumType.STRING), Spring Data will save the name of the entity in the database (look, we put a VARCHAR column). If you prefer, you could use EnumType.ORDINAL and Spring Data will save the ordinal value of the entity (1,2,3,etc..), so change the column to accept a numeric value

Click here https://www.emanuelepapa.dev/using-spring-data-to-persist-a-set-of-enums-in-a-many-to-many-relationship/

Upvotes: 1

Related Questions