Hibernate version: 2.1
Mapping documents:
Project class:
<hibernate-mapping package="Metier">
<class name="Projet" table="PROJET">
<id
column="IDPROJ"
name="Idproj"
type="integer"
>
<generator class="vm" />
</id>
<property
column="DATEDEB"
length="10"
name="Datedeb"
not-null="false"
type="date"
/>
<property
column="DATEFIN"
length="10"
name="Datefin"
not-null="false"
type="date"
/>
<property
column="DESCRIPTION"
length="250"
name="Description"
not-null="false"
type="string"
/>
<property
column="DESIGNATION"
length="50"
name="Designation"
not-null="false"
type="string"
/>
<many-to-one
class="Budget"
name="Idbud"
not-null="true"
>
<column name="IDBUD" />
</many-to-one>
<set inverse="true" name="RISQUESet">
<key column="IDPROJ" />
<one-to-many class="Risque" />
</set>
<set inverse="true" name="PROCESSUSSet">
<key column="IDPROJ" />
<one-to-many class="Processus" />
</set>
<set inverse="true" name="METRIQUESet">
<key column="IDPROJ" />
<one-to-many class="Metrique" />
</set>
<set inverse="true" name="ITERATIONSet">
<key column="IDPROJ" />
<one-to-many class="Iteration" />
</set>
</class>
</hibernate-mapping>
Iteration classes :
<hibernate-mapping package="Metier">
<class name="Iteration" table="ITERATION">
<id
column="IDIT"
name="Idit"
type="integer"
>
<generator class="vm" />
</id>
<property
column="DATEDEB"
length="10"
name="Datedeb"
not-null="false"
type="date"
/>
<property
column="DATEFIN"
length="10"
name="Datefin"
not-null="false"
type="date"
/>
<property
column="NUMERO"
length="10"
name="Numero"
not-null="false"
type="integer"
/>
<many-to-one
class="Projet"
name="Idproj"
not-null="true"
>
<column name="IDPROJ" />
</many-to-one>
<set inverse="true" name="METRIQUESet">
<key column="IDIT" />
<one-to-many class="Metrique" />
</set>
<set inverse="true" name="TACHESet">
<key column="IDIT" />
<one-to-many class="Tache" />
</set>
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():
Session session = HibernateUtil.currentSession();
Transaction tx = session.beginTransaction();
Projet proj = new Projet(new Integer(0));
proj.setDesignation("projet qui pue");
Iteration it = new Iteration(new Integer(0));
proj.addToITERATIONSet(it);
session.save(it); // i try whith this line and whithout
session.save(proj);
tx.commit();
Full stack trace of any exception that occurs:
no execption throwed
Name and version of the database you are using:
Pointbase (with the j2ee 1.4)
The generated SQL (show_sql=true):
Hibernate: insert into ITERATION (DATEDEB, DATEFIN, NUMERO, IDPROJ, IDIT) values (?, ?, ?, ?, ?)
Hibernate: insert into PROJET (DATEDEB, DATEFIN, DESCRIPTION, DESIGNATION, IDBUD, IDPROJ) values (?, ?, ?, ?, ?, ?)
Comment:
The project class had a collection (set) of Iteration, when i had an iteration to the project , when i look into the database, the iteration foreign key refering the project id is null
Is someone can help me ??
_________________ °oO Pierrox Oo°
|