openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Francesco Russo" <f.r.u.x....@gmail.com>
Subject Re: JPA question and i18n problem
Date Thu, 10 Jul 2008 09:01:14 GMT
Hi Julien,
it seems to me it's just a matter of proper fetch-configuration. I guess
that by default JPA does not eagerly fetch related persistent instances
unless you impose that.
You should take a closer look at the Users' Guide, maybe.

For example here
http://openjpa.apache.org/builds/1.1.0/apache-openjpa-1.1.0/docs/manual/manual.html#jpa_overview_meta_onetomanyyou
are suggested to use the FetchType annotation for marking those
references that map one-to-many relations. This should be the case for the
relation you have between Sculpture and Sculpture_i18n.

Hope this helps,
Francesco

On Thu, Jul 10, 2008 at 10:45 AM, Julien Martin <balteo@gmail.com> wrote:

> 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