Jesper de Jong wrote:There are multiple issues going on here.
The first one is: how do you store an enum in the database? There are different ways to do this, each with pros and cons.
1. You can store the enum ordinal (the index of the enum constant in the definition of the enum). Pros: simple and you don't need to add extra code to the enum. Cons: if you re-order the enum constants, or add a new constant in between existing constants, the ordinals will change and things break.
2. You can store the name of the enum constant as a string in the database. Pros: simple, you don't need extra mapping code. Cons: strings take up more space than a simple int value (such as an ordinal) in the database.
3. Have some explicit mapping from enum constants to codes, store those codes in the DB, and then translate back and forth as you save / load values from the DB. Pros: You don't have the problem of changing ordinals as with solution 1. Cons: Needs more code, because you need to do this mapping.
The second issue is displaying on the client side. This is a completely separate issue from how you store enum values in the database. You'll need to have some mapping mechanism (for example a Properties file) to convert enum values to display texts. But as I already said, this is separate from how you store enum values in the database. There is no need to store the display texts in the database whenever you need to store an enum value (which you seem to imply when you say "store key/value pairs in the database?").
1 - Email
2 - Mobile
3 - Fix
1 - EMAIL
2 - MOBILE
3 - FIX
EMAIL=Email
MOBILE=Mobile
FIX= Fix
{
"lodgerId": "",
"firstName": "paul",
"lastName": "houlde",
"contactPersonelMobile.phone": "4506778989",
"birthdate": "16/07/2015",
"entryDate": "16/07/2015",
"releaseDate": "31/07/2015",
"oldAddress.addressId": "",
"oldAddress.name": "bixi",
"oldAddress.address": "23 marie victorin",
"oldAddress.phone.phoneId": "",
"oldAddress.phone.phone": "1234567896",
"brandId": "26",
"brand": "Honda",
"modelId": "519",
"color": "#5484ed",
"year": "2000",
"licencePlate": "1h2r43",
"identityCardList[0].identityCardId": "",
"identityCardList[0].identityCardType": "1",
"identityCardList[0].value": "cadfadfa",
"identityCardList[1].identityCardId": "",
"identityCardList[1].identityCardType": "",
"identityCardList[1].value": "",
"identityCardList[0].expiration": "",
"identityCardList[2].identityCardId": "",
"identityCardList[2].value": "",
"identityCardList[2].expiration": ""
}