-->
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: How to map localized text
PostPosted: Wed Apr 05, 2006 4:55 pm 
Newbie

Joined: Wed Apr 05, 2006 4:33 pm
Posts: 5
I'm simplyfing, but I have the following db:
Code:
create table text
(
id integer primary key,
type_id integer,
reference_id integer,
language_code char(2),
value varchar(255)
);

create table recipe
(
id integer primary key
);

As for objects, I currently have:

@Entity
@Table(name="text")
class LocalizedText
{
int textType;
@Id
int id;
int reference_id;
String languageCode;
String value;
}

@Entity
@Table(name="recipe")
class Recipe
{
@Id
int id;

@OneToMany(targetEntity=LocalizedText)
@JoinColumn(name="reference_id", insertable=false, updatable=false)
@Cascade(CascadeType.ORPHAN)
@Where(type_id=1)
@MapKey(name="language_code")
Map<String, LocalizedText>name;
}



Now, here's the question.
I'd like to move the map into its own object, i.e. have a special object to keep track of my localized strings, something like:

Code:
public class Text
{
...
...
int typeId;
int referenceId;
Map<String, LocalizedText>values;
public toString(String languageCode)
{
return values.get(languageCode);
}

public class Recipe
{
int id;
Text name;
Text description;
Text instructions;
}

public class Ingredient
{
int id;
Text name;
}



But I have no idea what to do with my Text class, my first thought is that it has to extend AbstractPersistentCollection or something like that, and then the annotations would look something similar to the same annotations I have originally for the map (with the OneToMany and so on) but I'm not sure. Any ideas?


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.