Home > Mobile >  Spring Boot - Enums when to use?
Spring Boot - Enums when to use?

Time:02-02

I have a User Entity that has Nationality and Gender as properties. What is the best pratice? Use Enums for that or have a separated table?

I also plan to send all the Nationalities and Genders back to the frontend as json data.

Thank you.

CodePudding user response:

I would suggest using enums if there are no frequent updations in the properties

CodePudding user response:

If you do not want to do a new build and deploy to add a gender or nationality, then use a separate table, otherwise use an enum.

For nationality you can define an enum with a "nationality" property, e.g. ZA("South African"). The property can then contain spaces and accents.

CodePudding user response:

I would personally start with an enum if I find that I'm updating it too often or need other people to update it that would be a good time to transition it to a table.

  •  Tags:  
  • Related