Finanally我做了,得到了滿意的結果是這樣:
Customer Title TitleLocalization
-------- ------ -----------------
id |---1 id 1---| id
titleId N---| |---N titleId
firstName locale
lastName title (localized)
Customer類:
@Entity
public class Customer implements Serializable {
@ManyToOne(fetch = FetchType.EAGER)
private Title title;
}
Title類:
@Entity
public class Title implements Serializable {
@OneToMany(mappedBy = "title", fetch = FetchType.EAGER)
@MapKey(name = "locale")
private Map<Locale, TitleLocalization> localized;
}
而且TitleLocalization類:
@Entity
public class TitleLocalization implements Serializable {
private static final long serialVersionUID = 1L;
@ManyToOne
private Title title;
private Locale locale;
private String traslation;
所以我可以「輕鬆」地從視圖中獲取已翻譯的客戶標題:例如,
#{login.currCustomer.title.localized.get(localeManager.currLocale).title}
什麼是您的確切問題? – 2013-04-30 13:03:26