0

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.

2
  • Look at UUID, which is virtually unique. How big is the chance to get a Java UUID.randomUUID collision? Commented Jul 7 at 9:02
  • Thanks! That wasn't the question really. I'm looking to model this structure using Hibernate and cannot come up with the right approach because the relationships between the tables are not straight-forward Commented Jul 8 at 9:09

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.