Hibernate version: 2.17
In my database I have a table LOCATION to store Locations:
CREATE TABLE LOCATION (
location_id int, /* Primary Key */
location_name varchar(20) )
Now the description of locations are stored in a different way w.r.t. different languages. For that I have 3 tables :
First a LANGUAGE table to store languages:
CREATE TABLE LANGUAGE (
language_id int, /* Primary Key */
language_name varchar(20) )
Then a TABLE table to store tables whose description will be stored:
CREATE TABLE TABLE (
table_id int, /* Primary Key */
table_name varchar(50),
table_keycolumn_name varchar(50) )
And lastly a TRANSLATION table to store descriptions:
CREATE TABLE TRANSLATION (
translation_id int, /* Primary Key */
language_id int, /* Foreign Key to LANGUAGE */
table_id int, /* Foreign Key to TABLE */
key_value int,
description varchar(100) )
For example this way the data is tored :
location_id location_name
--------------------------------
101 Miss
102 Bram
language_id language_name
----------------------------------
1 English
2 French
table_id table_name table_keycolumn_name
----------------------------------------------------------------
1 LOCATION location_id
2 DEPARTMENT department_id
translation_id language_id table_id key_value description
----------------------------------------------------------------------------
1 1 1 101 Mississauga
2 2 1 101 Mississauga (fr)
3 1 1 102 Brampton
4 2 1 102 Brampton (fr)
There is no foreign key relationship in this type of model between a code table (in this case LOCATION) and the translation table.
what I would like is to build the mapping file of LOCATION in such a way that when I try to retrieve a LOCATION, it can also retrieve its respective descriptions (for all languages) in the same SQL statement. Is it possible? If yes then how?
Thanks
JY
|