In a no sql database, it is advised to have a type parameter in all the objects/documents that are saved. This type param is like the table name. So I created the following enum
And when saving the a document, I HAVE do a Type.CUSTOMER.getName(). All this works but I wanted to know if there is a better way to do this.
Pros: standard enum pattern followed everywhere.
Cons: Nothing preventing you to have the same name for 2 different enum values which in this scenario is wrong.(2 tables with same name)
Also if I am using a jackson object mapper, I have to create some kind of custom mapping so that what is saved to database is "customer" and not "CUSTOMER"
If I want to save "CUSTOMER" in the database and not "customer", then all is good as I can simply remove the "name" attribute and we are done. But if I want to store in lower caps one other option is simply to have this:
Much much simpler and solves all the problems listed above, but the thing is that I am not using the standard conventions of using CAPS for enums.
What do you think is the better approach?
Also I though this is a design question so did not post it in "OTHER BIG DATA" forums