-->
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: Composite key part as map key?
PostPosted: Wed Jan 11, 2006 6:58 am 
Newbie

Joined: Tue Jan 10, 2006 8:53 am
Posts: 1
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]


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.