I'm trying to create java resources using Hibernate framework to represent some Business entity like Product or Address along with Localization. I want to use one localization table for all entities in the project where the localization key would consist of ENTITY_ID, ENTITY_TYPE and LOCALE. Also it would be great to keep ENTITY_ID unique across all business entities so that ADDRESS.ID would never be equal to PRODUCT.ID. My table structure is as follows:
Table: PRODUCTS:
| PROD_ID | PRICE |
|---|---|
| 1111 | 99.9 |
| 2222 | 88.8 |
Table ADDRESS:
| ADDRESS_ID |
|---|
| aaaa |
| bbbb |
Table: LOCALIZED_DATA:
| ENTITY_ID | ENTITY_TYPE | LOCALE | VALUE |
|---|---|---|---|
| 1111 | Name | en_US | Name in English |
| 1111 | Name | es_ES | Nombre en español |
| 1111 | Description | en_US | Description in English |
| 1111 | Description | es_ES | Descripción en español |
| aaaa | Street | en_US | Street name in English |
| aaaa | City | en_US | City name in English |
| aaaa | Street | es_ES | Nombre de la calle en español |
| aaaa | City | es_ES | Nombre de la ciudad en español |
I tried looking for examples of such mapping, but couldnt find anything. All examples use simple table relations and that would mean I have to define more tables which seems to be a waste. Any help is appreciated.