Hi Carlos,

    I've traced down the problem in
org.exolab.castor.persist.ClassMolder.create (line 991) method
(see
http://virtuals.intalio.com/cgi-bin/cvsweb.cgi/castor/src/main/org/exolab/ca
stor/persist/ClassMolder.java?annotate=1.54&cvsroot=castor&only_with_tag=tag
_0_9_3). At this point, from my
understanding, the variable "oo" contains the value of a "Videoformat" in my
example and we need to check if it is persistent.
But since the identity of this object is already known (we set the "uid"
field), then this field is not persistent (tx.isPersistent(oo) is false).

    To solve this problem, I removed the condition "tx.isPersistant(oo)" to
force the persistence of "oo". In that case, the relation is
always written even if we already know the identity of "Videoformat". As for
the exception thrown while loading, I've found that it was
caused by my using accentuated characters in the database field that are not
compatible with UTF-8. The moment I changed the
accents for characters entities (é for �), everything was right.

    If someone knows that I've done something wrong by removing the
condition or if there is a better way to handle this, let
me know.

Good day

S�bastien Dumais

----- Original Message -----
From: "Carlos Illana" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, August 03, 2001 2:06 AM
Subject: Re: [castor-dev] Many-Many relation problems


> Hi Dumais,
>
> I have the same problem but the list has not give me an answer.
> I get the the entry in the m:n relation table added when both objects are
> new, but when I try to relate the object with objects already in the
> database the record in the relation table is not added.
>
> Maybe Castor development team can give us an answer.
>
> Regards,
> Carlos
>
> > Hi all,
>
> >       I've been using Castor for some time to map a complex set of
> objects
> > but I've stumbled across
> > a problem with a many-many relation. The problem I have is that when I
> > create a new "Movie" object
> > and I add a "Videoformats" to it, Castor does not add the entry in the
> > relation table "videoformat_list".
>
> >       When I remove the condition tx.isPersistant in ClassMolder
> > (org.exolab.castor.persist.ClassMolder:915),
> > the entry is added but when I try loading a "Movie" back, I get this
> > exception:
> >
> > --
> > org.exolab.castor.jdo.PersistenceException: Object, Title@7ca8, links to
> > another object, Movie@7808b9 that is not loaded/updated/created in this
> > transaction
> > --
>
> > I don't really understand what that means and how to make this m-n
> > relation work.
>
>
>
> >       The mapping is:
>
> > <mapping>
> >   <!-- class declaration for Category here -->
>
> >   <class identity="uid" name="Videoformats">
> >     <description>Describes a videoformat</description>
> >     <map-to table="videoformats"/>
>
> >     <field name="uid" type="integer">
> >       <description>Primary Key</description>
> >       <sql name="uid" type="integer"/>
> >     </field>
>
> >     <field name="videoformatDescription" type="VideoformatDescription"
> > collection="vector" required="true">
> >       <description></description>
> >       <sql many-key="videoformat"/>
> >     </field>
> >   </class>
>
> >   <class identity="lang content" name="VideoformatDescription">
> >     <description></description>
> >     <map-to table="videoformats_desc"/>
>
> >     <field name="lang" type="java.lang.String">
> >       <sql name="lang" type="varchar"/>
> >     </field>
>
> >     <field name="content" type="java.lang.String">
> >       <sql name="description" type="varchar"/>
> >     </field>
> >   </class>
>
> >   <class identity="uid" name="Movie" key-generator="uidgen">
> >     <map-to table="movies"/>
>
> >     <!-- some removed for sake of brievety -->
>
> >     <field name="uid" type="java.lang.String">
> >       <description>Primary Key for Titles table</description>
> >       <sql name="uid" type="integer"/>
> >     </field>
>
> >     <!-- ********************** 1-N relation, works fine
> > ********************************** -->
> >     <field name="category" type="com.dvdsoon.ebeans.title.Category"
> > required="true">
> >       <description>The category of this movie</description>
> >       <sql name="category"/>
> >     </field>
> >     <!--
> >
> **************************************************************************
> *******
> > -->
>
> >     <!-- *********************** M-N relation, that's the
> > trouble************************* -->
> >     <field name="videoformats"
> > type="com.dvdsoon.ebeans.title.Videoformats" collection="vector"
> > required="true">
> >       <description>Videoformats of this movie</description>
> >       <sql many-table="videoformat_list" many-key="movie"
> > name="videoformat"/>
> >     </field>
> >     <!--
> >
> **************************************************************************
> ********
> > -->
>
> >     <field name="version" type="integer">
> >       <description>The version number of this entry</description>
> >       <sql name="version_number" type="integer"/>
> >     </field>
>
> >   </class>
> > </mapping>
>
> > Thank you in advance for your time..
>
>
> > S�bastien Dumais
>
> > -----------------------------------------------------------
> > 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
>

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

Reply via email to