Hi!
Is it possible to map a Map<String, String> to a secondary table using Hibernate Annotations? For example:
Code:
@Entity
public class Text
{
@Id
private Long id;
@SecondaryTable(???)
private Map<String, String> translations;
public Long getId() { ... }
public Map<String, String> getTranslations() { ... }
}
The idea is to allow e.g.
Code:
Text text = myTextDAO.get(myTextId);
// Get a translation
String english = text.getTranslations().get(Locale.ENGLISH.getLanguage());
// Add a translation
text.getTranslations().put("sv", "Hej");
The secondary table would concist of TEXT_ID, LANGUAGE_ID, TRANSLATION with (TEXT_ID, LANGUAGE_ID) as primary key.
I know it's possible to map string -> entity, but that's not what I'm looking for right now. I think this is possible with an XML configuration as well, but I haven't figured it out in JPA.
Regards,
Nille