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