Ronald,
Please see inline...

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

> That doesn't seem to make sense.  ObjectTwo doesn't only have to be
> associated with ObjectOne types, but many other types as well.  
> It's a
> common attribute of types in this system.
> 
> For example, suppose ObjectTwo is color while ObjectOne is a car.  
> There is
> a many-to-many relationship between the two, even though it only 
> makes sense
> to associate them one way.  Perhaps you also want to add fruits to the
> database and associate them in a many-to-many fashion with colors. 
> Would
> the color type now have to support a reverse relationship between 
> the cars
> AND the fruits?
> 

With regards to Castor's (current) behavior, you should specify many-to-many 
relations to both cars and fruits in the color's mapping.
Of course, you're going to specify cars and fruits fileds in color as lazy 
loaded, so when you load a color, not all of the cars and fruits using that 
color are loaded too.


> -Ron
> 
> -----Original Message-----
> From: [EMAIL PROTECTED] [EMAIL PROTECTED]
> Sent: Monday, May 02, 2005 8:22 AM
> To: [email protected]
> Subject: Re: RE: [castor-dev] many-to-many mapping..
> 
> 
> Ronald,
> I think it's required to map both sides of the relation.
> Try doing it.
> 
> 
> Regards,
> Emir
> 
> 
> ----- Original Message -----
> From: Ronald Rudy <[EMAIL PROTECTED]>
> Date: Monday, May 2, 2005 2:23 pm
> Subject: RE: [castor-dev] many-to-many mapping..
> 
> > Here is my mapping:
> >
> >   <class name="com.xyz.ObjectOne" identity="oneId"
> > key-generator="SEQUENCE">
> >      <description>"First of Many-to-Many Object"</description>
> >      <map-to table="object_one"/>
> >      <cache-type type="none"/>
> >      <field name="oneId" type="integer">
> >         <sql name="object_one_id" type="integer"/>
> >      </field>
> >
> >       ...
> >
> >      <field name="objectTwo" type="com.xyz.ObjectTwo"
> > collection="arraylist">
> >        <sql name="object_two_id" many-
> table="objectone_objecttwo_map"> many-key="object_one_id" key-
> generator="SEQUENCE" />
> >      </field>
> >   </class>
> >
> >
> >   <class name="com.xyz.ObjectTwo" identity="twoId"
> > key-generator="SEQUENCE">
> >      <description>"Second of Many-to-Many Object"</description>
> >      <map-to table="object_two"/>
> >      <cache-type type="none"/>
> >      <field name="twoId" type="integer">
> >         <sql name="object_two_id" type="integer"/>
> >      </field>
> >
> >       ...
> >
> >   </class>
> >
> >
> > I didn't include a reverse mapping from the ObjectTwo -> ObjectOne
> > because I
> > don't have/need a property on the com.xyz.ObjectTwo class to get
> > back to
> > ObjectOne.
> >
> > The mapping table objectone_objecttwo_map has three relevant fields:
> >
> >     primary key of the mapping table itself
> >     foreign key of 'object_one' record this is associated with
> >     foreign key of 'object_two' record this is associated with
> >
> > -Ron
> >
> > -----Original Message-----
> > From: Werner Guttmann [EMAIL PROTECTED]
> > Sent: Monday, May 02, 2005 8:12 AM
> > To: [email protected]
> > Subject: AW: [castor-dev] many-to-many mapping..
> >
> >
> > Ronald,
> >
> > there's no need to define a mapping object, as your many-to-may
> > relationwill be handled automatically by Castor. And this should
> > by definition
> > include the handling of the keys in the mapping table. It looks
> > like you
> > have got the mapping slightly wrong, so can you please post the
> > relevantmapping section, the DDL used to create the tables in
> > question and some
> > information about the classes engaging in such mapping ?
> >
> > Werner
> >
> > -----Urspr�ngliche Nachricht-----
> > Von: Ronald Rudy [EMAIL PROTECTED]
> > Gesendet: Montag, 02. Mai 2005 14:08
> > An: [email protected]
> > Betreff: [castor-dev] many-to-many mapping..
> >
> >
> > I have configured Castor to support a many-to-many relationship
> > between two
> > types of objects, but I'm getting an error.  This is because the
> > mappingtable itself (in Oracle) contains a primary key of its own,
> > and this is not
> > automatically assigned by Castor.  So when a new relationship is
> > created,this primary key is null and the database throws an error.
> >
> > I don't have control over the database schema - is there any way to
> > configure Castor to recognize that the configured many-table has a
> > primarykey and the key can be created using the sequence key
> > generator?  (the
> > sequence key generator works fine for everything else)  Or am I
> > going to be
> > forced to create a "map" object that handles the relationship
> > 'manually'?
> > -Ron
> >
> >
> >
> 
> 
> 
>


Reply via email to