Hi Barley, If I understand you're problem correctly it's fairly simple. The reason Castor is checking for 'observation.disability_id' is because in in your field mapping (which I assume is in a observation object), you specify the 'name' attribute of the 'sql' element. If you remove the name (which is not needed, Castor can type from the 'type' definition) you should receive the results you expect. I hope that helps.
Vincent -----Original Message----- From: Barley [mailto:[EMAIL PROTECTED] Sent: Wednesday, July 23, 2003 2:01 PM To: [EMAIL PROTECTED] Subject: [castor-dev] Castor looking in wrong table for relationship In trying to map my object Observation to my object Disability in a many to many relationship, I use the following field element in the Observation class: <field name="allDisabilities" type="mypackage.Disability" required="true" collection="vector"> <sql name="disability_id" many_table="observation_disabilities" many-key="observation_id"/> </field> But, strangely, I get the following error from Castor: java.sql.SQLException: Column not found, message from server: "Unknown column 'observation.disability_id' in 'field list'" Shouldn't Castor be looking in the observation_disabilities table?? I have successfully mapped Observation to Disability like so: <field name="observations" type="mypackage.Observation" required="true" collection="vector"> <sql name="observation_id" many-table="observation_disabilities" many-key="disability_id"/> </field> ...and that works fine. It saves the relationship between the two objects in the observation_disabilities table. So, why doesn't the field definition in the Observation class work the same way to relate the two objects? It's very confusing. Also, I read that with Castor, many-to-many relationships *have* to be two-way. Yet, for me it only works if I define the relationship under Disability, but not under Observation. The problem is, that while I am able to save the objects and their relationships by calling aDisability.addObservation(anObservation), I am unable to restore an Observation from the database with its associated Disability's because for some reason Castor doesn't understand where to look for the relationship when going in that direction. I'd sure appreciate if someone can shed some light on this, because it has me *very* confused. Thanks! Gregg ----------------------------------------------------------- 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
