-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Problems with mapping a Map
PostPosted: Mon Oct 22, 2012 11:23 am 
Newbie

Joined: Tue Aug 17, 2010 1:13 pm
Posts: 2
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:
Image

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-


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.