Hi,
  Your problem description is interesting. I have come across and also heard
others express similar issue where a Product or Item (or Sculpture, which is
more interesting than Product/Item) requires to select to one of the many
descriptions based of a specific Locale.  
  OpenJPA provides a neat solution to solve this problem using non-standard
joins [1] with constant columns. While a non-standard join can designate a
constant column (such as the locale string in your example) but the value
remains constant -- there is no obvious way to change it dynamically. So,
for example, you set the constant value in mapping descriptor to 'fr' --
OpenJPA will join Sculpture to its French descriptions. To change it to
English, one has to change the constant value in mapping to 'en' -- that is
not very nice.

   To continue your example, one will perhaps prefer a transparent dynamic
solution like below:

    setLocale(Locale.ENGLISH);
    Sculpture s1 = findBySculptureID(100);
    assertEquals(s1.getDescription().getText(),  "a woman's bust");

    setLocale(Locale.FRENCH);
    Sculpture s2 = findBySculptureID(100); // same Sculpture, but invoked in
French Locale
    assertEquals(s2.getDescription().getText(), "buste de femme");

     

[1]
http://openjpa.apache.org/docs/latest/manual/manual.html#ref_guide_mapping_notes_nonstdjoins

-- 
View this message in context: 
http://n2.nabble.com/JPA-question-and-i18n-problem-tp471792p472773.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.

Reply via email to