I'm working on a project where I have to add dynamic internationalization, so that i.e. the GUI can be translated by an administrator. So everything has to be stored in a database.
Until now the project was implemented using Hibernate 3.2 but I'm running into problems I can't get solved on my own.
Before I desperately dump hibernate and rewrite the whole application with plain SQL (and maybe be finished in a fraction of the time...) I hope someone else can give me a hint how to get the hibernate-configuration to work.
So here is the simplified view on the database schema:
There are several tables (here: help and config) which contain entries that have to be translated into several languages.
The table "translations" contains the localized text. The table "mappings" maps the keys from "config" and "help" to one unique key, which is referenced by the translations. Only one element of the columns config_id and help_id is used on the same row, the other one has to be null.
The POJO's look both like this:
Code:
public class Help {
int id;
String key;
Map<Integer, String> translations;
// ^ ^ should contain translations.text
// ^ should contain languages.id
}
I've managed to get this working without the mappings table and with only one referencing table (i.e. config).
But as soon as i try to add the second table (help) or the mappings-table, I just can't find out how to get a working configuration.
This is the snippet of the hibernate-configuration I use:
Code:
<class name="HelpEntry" table="help" >
<id name="id" access="field">
<generator class="native"/>
</id>
<property name="key" length="128" access="field"/>
<map name="locales" access="field" cascade="all" table="translations">
<key foreign-key="id"/>
<map-key column="language_id" type="integer"/>
<element column="text" type="string"/>
</map>
</class
Any hint or help is very appreciated.
Thanks in advance
-Marc-