I have answered this one in the mean time.
You need to specify your cars and fruits as lazy loaded fields in the color's 
mapping.

Regards,
Emir


----- Original Message -----
From: Ronald Rudy <[EMAIL PROTECTED]>
Date: Monday, May 2, 2005 2:59 pm
Subject: RE: [castor-dev] many-to-many mapping..

> If this is the case, then can I do it in such a way that the 
> second object
> does not load a collection of the first by default?  There's no 
> need to load
> all the cars and fruits a specific color is associated if all I 
> want to do
> is load that color. (referring to my last example)
> 
> -Ron
> 
> -----Original Message-----
> From: Werner Guttmann [EMAIL PROTECTED]
> Sent: Monday, May 02, 2005 8:33 AM
> To: [email protected]
> Subject: AW: [castor-dev] many-to-many mapping..
> 
> 
> Ronald,
> 
> Castor unfortunately will require you to define the reverse leg of the
> many-to-many relation as well, even if you don't need from within your
> application. Without both legs, this will not work. And that's 
> exactly the
> reason why you are seeing the keys not being set.
> 
> Regards
> Werner
> 
> wg> -----Urspr�ngliche Nachricht-----
> wg> Von: Ronald Rudy [EMAIL PROTECTED]
> wg> Gesendet: Montag, 02. Mai 2005 14:23
> wg> An: [email protected]
> wg> Betreff: RE: [castor-dev] many-to-many mapping..
> wg>
> wg>
> wg> Here is my mapping:
> wg>
> wg>    <class name="com.xyz.ObjectOne" identity="oneId"
> wg> key-generator="SEQUENCE">
> wg>       <description>"First of Many-to-Many Object"</description>
> wg>       <map-to table="object_one"/>
> wg>       <cache-type type="none"/>
> wg>       <field name="oneId" type="integer">
> wg>          <sql name="object_one_id" type="integer"/>
> wg>       </field>
> wg>
> wg>        ...
> wg>
> wg>       <field name="objectTwo" type="com.xyz.ObjectTwo"
> wg> collection="arraylist">
> wg>         <sql name="object_two_id"
> wg> many-table="objectone_objecttwo_map"
> wg> many-key="object_one_id" key-generator="SEQUENCE" />
> wg>       </field>
> wg>    </class>
> wg>
> wg>
> wg>    <class name="com.xyz.ObjectTwo" identity="twoId"
> wg> key-generator="SEQUENCE">
> wg>       <description>"Second of Many-to-Many Object"</description>
> wg>       <map-to table="object_two"/>
> wg>       <cache-type type="none"/>
> wg>       <field name="twoId" type="integer">
> wg>          <sql name="object_two_id" type="integer"/>
> wg>       </field>
> wg>
> wg>        ...
> wg>
> wg>    </class>
> wg>
> wg>
> wg> I didn't include a reverse mapping from the ObjectTwo ->
> wg> ObjectOne because I
> wg> don't have/need a property on the com.xyz.ObjectTwo class
> wg> to get back to
> wg> ObjectOne.
> wg>
> wg> The mapping table objectone_objecttwo_map has three relevant 
> fields:wg>
> wg>   primary key of the mapping table itself
> wg>   foreign key of 'object_one' record this is associated with
> wg>   foreign key of 'object_two' record this is associated with
> wg>
> wg> -Ron
> wg>
> wg> -----Original Message-----
> wg> From: Werner Guttmann [EMAIL PROTECTED]
> wg> Sent: Monday, May 02, 2005 8:12 AM
> wg> To: [email protected]
> wg> Subject: AW: [castor-dev] many-to-many mapping..
> wg>
> wg>
> wg> Ronald,
> wg>
> wg> there's no need to define a mapping object, as your
> wg> many-to-may relation
> wg> will be handled automatically by Castor. And this should by
> wg> definition
> wg> include the handling of the keys in the mapping table. It
> wg> looks like you
> wg> have got the mapping slightly wrong, so can you please post
> wg> the relevant
> wg> mapping section, the DDL used to create the tables in
> wg> question and some
> wg> information about the classes engaging in such mapping ?
> wg>
> wg> Werner
> wg>
> wg> -----Urspr�ngliche Nachricht-----
> wg> Von: Ronald Rudy [EMAIL PROTECTED]
> wg> Gesendet: Montag, 02. Mai 2005 14:08
> wg> An: [email protected]
> wg> Betreff: [castor-dev] many-to-many mapping..
> wg>
> wg>
> wg> I have configured Castor to support a many-to-many
> wg> relationship between two
> wg> types of objects, but I'm getting an error.  This is
> wg> because the mapping
> wg> table itself (in Oracle) contains a primary key of its own,
> wg> and this is not
> wg> automatically assigned by Castor.  So when a new
> wg> relationship is created,
> wg> this primary key is null and the database throws an error.
> wg>
> wg> I don't have control over the database schema - is there any 
> way to
> wg> configure Castor to recognize that the configured
> wg> many-table has a primary
> wg> key and the key can be created using the sequence key
> wg> generator?  (the
> wg> sequence key generator works fine for everything else)  Or
> wg> am I going to be
> wg> forced to create a "map" object that handles the
> wg> relationship 'manually'?
> wg>
> wg> -Ron
> wg>
> wg>
> 
> 
>


Reply via email to