openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Julien Martin" <bal...@gmail.com>
Subject JPA question and i18n problem
Date Thu, 10 Jul 2008 08:45:36 GMT
Hello,
I have the following two tables:

{code}

CREATE TABLE Sculpture
(
    sculpture_ID integer NOT NULL PRIMARY KEY,
    hauteur integer NOT NULL,
    largeur integer NOT NULL,
    annee year NOT NULL,
    prix double,
    nombreExemplaires integer NOT NULL,
    actif bool DEFAULT false NOT NULL
);

CREATE TABLE Sculpture_i18n
(
    sculpture_id integer NOT NULL ,
    locale char(2) NOT NULL ,
    titre varchar (50) NOT NULL,
    description varchar(255),
    FOREIGN KEY(sculpture_id) REFERENCES Sculpture (sculpture_ID)
);

{code}

I have generated the associated entity classes using netbeans.

in the Sculpture_i18n table, I have as many lines per sculpture as there are
locales in the app. Say I have two locales: French and English. I'll have
the following rows in the Sculpture_i18n:

1  "en"  "woman" "a woman's bust"
1  "fr"  "femme" "buste de femme"
2 "en" "dog" "a black dog"
2 "fr"  "chien" "un chien noir"
etc...

I want to be able to retrieve a sculpture together with  its localized
information using jpa.

As of now my DAO looks like that and does not handle i18n:

{code} public Sculpture findBySculptureID(Integer sculptureId) {
        return (Sculpture)
entityManager.createNamedQuery("Sculpture.findBySculptureID").setParameter("sculptureID",
sculptureId).getSingleResult();
    }
{code}

Does anyone have any sugggestion?

Julien.

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message