Hi,
I'm pretty a newbie with mapping technologies, and i have a problem with mapping two tables in a single class.
My problem is as follows:
I want to implement i18n functionalities at database level for the countries, places, ... and any other geographical data that may be stored in the database.
So if an english speaking user would log into the application the coutry names, etc would be printed in his language (english: united kingdom, italian: regno unito, ....)
In the legacy db the "schema of the relationships is as follows" (example with countries):
Code:
+-------------+ +-----------------+ +----------------+
|country | | country_i18n | | language |
+-------------+ 1..1 --------- 0..n +-----------------+ 0..n ------------- 1..1+----------------+
| id (pk) | | id (pk) | | id (pk) |
| code (uk) | | name | | code (uk) |
+-------------+ | language_id (fk)| | name |
| country_id (fk) | +----------------+
+-----------------+
Now, is there a way to map all of this stuff (rows of tables country and contry_i18n) in a single table, telling hibernate to use le language code or any other unique value (which is unique) as discriminator value?
Someone told me to try solving that by mapping the countries in a hashmap like Map<enumLanguage,Country> but I can't understand how... and if it's still possible
Any suggestions, or other possible solutions would be very much appreciated!
Thank you very much in advance. :)