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

Reply via email to