Hibernate version:3.1
Name and version of the database you are using:PostgreSQL 8.0
I have some difficulties retrieving data from a table with a composite key.
For a multilang app instead of directly containing the string, every text which is translatable is referenced by a translation ID (abbreviated example):
Code:
CREATE TABLE titles (
id numeric(20),
text numeric(20),
CONSTRAINT pk_title PRIMARY KEY (id)
)
This ID references the table containing the translated texts in all available languages.
Code:
CREATE TABLE translations (
translationid numeric(20),
languageid numeric(3),
text varchar(1000),
CONSTRAINT pk_translation PRIMARY KEY (translationid, languageid)
)
So there can be a Title:
Code:
INSERT INTO titles VALUES (1, 1000)
referencing the Translations:
Code:
INSERT INTO translations VALUES (1000, 1, 'Mister')
INSERT INTO translations VALUES (1000, 2, 'Signor')
INSERT INTO translations VALUES (1000, 3, 'Herr')
Since translation has a composite key, of which one part (the language ID) is not an attribute, but provided as a parameter, I thought about putting all translations into a map using the language ID as key, so I could do:
Code:
String englTitle
= (String) ((Map) ((Title) title).getNames()).get(1);
Unfortunately I (being quite new to Hibernate) could not find any examples of a comparable mapping.
Question: Do you have any hints how such a mapping would look like? Any thoughts are appreciated, also on using a map as I am not sure that's the best solution.[/code]