Sorry... I meant to attach this file to the previous message. Mapping file contents follow:
<!DOCTYPE mapping PUBLIC "-//EXOLAB/Castor Mapping DTD Version 1.0//EN" "http://castor.exolab.org/mapping.dtd"> <mapping> <key-generator name="SEQUENCE"> <param name="sequence" value="global_seq"/> </key-generator> <class name="com.sandcherry.services.configuration.common.ServicePackage" identity="id" key-generator="SEQUENCE" xml="servicePackage"> <description>ServicePackage</description> <cache-type type="unlimited"/> <map-to table="service_packages"/> <field name="id" type="integer"> <sql name="id" type="integer"/> <xml name="id" node="attribute"/> </field> <field name="name" type="string"> <sql name="name" type="varchar"/> <xml name="name" node="attribute"/> </field> <field name="description" type="string"> <sql name="description" type="varchar"/> <xml name="description" node="attribute"/> </field> <field name="defaultService" type="com.sandcherry.services.configuration.common.Service"> <sql name="default_service_id"/> <xml name="defaultService" node="element"/> </field> <field name="services" type="com.sandcherry.services.configuration.common.Service" required="false" collection="collection"> <sql name="service_id" many-table="service_package_service_med" many-key="service_package_id"/> <xml name="service" node="element"/> </field> </class> <class name="com.sandcherry.services.configuration.common.Service" identity="id" key-generator="SEQUENCE" xml="service"> <description>Service</description> <cache-type type="unlimited"/> <map-to table="services"/> <field name="id" type="integer"> <sql name="id" type="integer"/> <xml name="id" node="attribute"/> </field> <field name="name" type="string"> <sql name="name" type="varchar"/> <xml name="name" node="attribute"/> </field> <field name="description" type="string"> <sql name="description" type="varchar"/> <xml name="description" node="attribute"/> </field> <field name="servicePackages" type="com.sandcherry.services.configuration.common.ServicePackage" required="false" collection="collection"> <sql name="service_package_id" many-table="service_package_service_med" many-key="service_id"/> <xml name="servicePackage" node="element"/> </field> <!-- <field name="resourcePools" type="com.sandcherry.services.configuration.common.ResourcePool" required="false" collection="collection"> <sql name="resource_pool_id" many-table="service_resource_pool_med" many-key="service_id"/> <xml name="resourcePool" node="element"/> </field> --> </class> </mapping> -----Original Message----- From: Gary Khominsky [mailto:[EMAIL PROTECTED]] Sent: Tuesday, February 26, 2002 3:15 PM To: [EMAIL PROTECTED] Subject: Re: [castor-dev] Many to Many Issue Hi Steve, It would be nice to see your mapping file Thanks Gary -----Original Message----- From: Steve Earl [mailto:[EMAIL PROTECTED]] Sent: Wednesday, February 27, 2002 9:05 AM To: [EMAIL PROTECTED] Subject: [castor-dev] Many to Many Issue Hi, I'm seeing some strange behaviour with many to many relationships and sequence key generators. I have a simple many to many relationship setup between ServicePackage objects and Service objects. The code to persiste the objects follows: db.begin(); ServicePackage sp = new ServicePackage(); sp.setName("Service Package " + System.currentTimeMillis()); Service s1 = new Service(); s1.setName("Service 1 " + System.currentTimeMillis()); Service s2 = new Service(); s2.setName("Service 2 " + System.currentTimeMillis()); sp.addService(s1); sp.addService(s2); db.create(sp); db.commit(); db.close(); Everything appears to go fine from the java side. However, when I query the database I seen that my join table (service_package_service_med) I have three (3) rows rather than the expected two rows. The rows contain the following data: service_package_id service_id 1 0 1 2 1 3 Somehow the Castor framework in inserting an "invalid" row into my join table... that row being the one with the zero (0) for the service_id value. Does anyone have any idea how this could be happening? Steve... ----------------------------------------------------------- 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