I found the answer of my problem...
I was using Castor9.3. And with the newer version castor 9.3.9 there is no
problem
...

> Hi,
> So I have a 1-to-many relation between two tables : toto and tableau
> toto (id, nom)
> tableau (id, totoid, nombre)
>
> When i browse my table toto with a requete like "select t from toto t"
> , I get all occurences of my table tableau in a vector named tableau.
> And when i browse this vector tableau, i got some problems...
> I have three tableau per table toto in my database.
> And when i browse each tableau in each toto i got something like this :
> id : 1
> nom : toto
> tableau.elementAt(0) = 1
> tableau.elementAt(1) = 6
> tableau.elementAt(2) = 11
> id : 2
> nom : toto
> tableau.elementAt(0) = 1
> tableau.elementAt(1) = 6
> tableau.elementAt(2) = 11
> tableau.elementAt(3) = 2
> tableau.elementAt(4) = 7
> tableau.elementAt(5) = 12
>
> In my second occurence of my table toto, i got six element in my vector
> instead of the three that are in my base. The first three elements comes
> from my first occurence of my table toto and the others are in my
> database : they are what i want...
>
> look the results of some requetes from my database :
> test=> select * from tableau;
>  id | totoid | nombre
> ----+--------+--------
>   1 |      1 |      1
>   2 |      2 |      2
>   6 |      1 |      6
>   7 |      2 |      7
>  11 |      1 |     11
>  12 |      2 |     12
>
> test=> select * from toto;
>  id |         nom
> ----+----------------------
>   1 | toto
>   2 | toto
> (2 rows)
>
> If someone can help me please answer me...
> I give you my sources :
>
> Here is my Toto.java :
>
> public class Toto {
>  private int id;
>  private String nom;
>  private Vector tableau = new Vector();
> .......
>
> Here is my Client.java :
> [...]
> db = jdo.getDatabase();
> db.begin();
> oql = db.getOQLQuery( "SELECT t FROM Toto t ORDER BY t.id" );
> results = oql.execute();
> while ( results.hasMore() ) {
>    Toto toto;
>    toto = (Toto) results.next();
>    System.out.print( "id : " + toto.getId()+ "\nnom : " + toto.getNom()
> + "\n");
>
>    for ( int i=0 ; i<toto.getTableau().size() ; i++ ) {
>     System.out.println( "tableau.elementAt(" + i + ") = " +
> (Tableau)toto.getTableau().elementAt(i) );
>    }
>   }
> db.commit();
> db.close();
> [...]
>
> And this is my mapping.xml :
>
> <mapping>
>   <class name="Toto" identity="id">
>     <description>Toto</description>
>     <map-to table="toto"/>
>     <field name="id" type="integer" >
>       <sql name="id" type="integer"/>
>     </field>
>     <field name="nom" type="java.lang.String">
>       <sql name="nom" type="char"/>
>     </field>
>     <field name="tableau" type="Tableau" required="true"
> collection="vector">
>       <sql many-key="totoid"/>
>     </field>
>   </class>
>
>   <class name="Tableau" identity="id">
>     <description>Tableau</description>
>     <map-to table="tableau"/>
>     <field name="id" type="integer" >
>       <sql name="id" type="integer"/>
>     </field>
>     <field name="totoId" type="Toto">
>       <sql name="totoid"/>
>     </field>
>     <field name="nombre" type="integer" >
>       <sql name="nombre" type="integer"/>
>     </field>
>   </class>
> </mapping>
>
> -----------------------------------------------------------
> If you wish to unsubscribe from this mailing, send mail to
> [EMAIL PROTECTED] with a subject of:
>         unsubscribe castor-dev

----------------------------------------------------------- 
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
        unsubscribe castor-dev

Reply via email to