Hibernate version: 3.2.6-ga
Mapping documents:
Name and version of the database you are using:mysql 5.0
The generated SQL (show_sql=true): Hibernate:
/* named HQL query Sculpture.findBySculptureID */ select
sculpture0_.sculpture_ID as sculpture1_2_,
sculpture0_.actif as actif2_,
sculpture0_.annee as annee2_,
sculpture0_.hauteur as hauteur2_,
sculpture0_.largeur as largeur2_,
sculpture0_.nombreExemplaires as nombreEx6_2_,
sculpture0_.prix as prix2_
from
jbm.Sculpture sculpture0_
where
sculpture0_.sculpture_ID=?
Hibernate:
/* load one-to-many com.jeanbaptistemartin.domain.Sculpture.sculpturei18nCollection */ select
sculpturei0_.sculpture_id as sculpture2_1_,
sculpturei0_.locale as locale1_,
sculpturei0_.locale as locale1_0_,
sculpturei0_.sculpture_id as sculpture2_1_0_,
sculpturei0_.description as descript3_1_0_,
sculpturei0_.titre as titre1_0_
from
jbm.Sculpture_i18n sculpturei0_
where
sculpturei0_.sculpture_id=?
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)
);
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();
}
Does anyone have any sugggestion?
Julien.
PS The pk of sculpturei18n is the composition of "sculptureid" and "locale"