I am trying to save relationships between two tables into a join table.  I am not able to save them.  I have two tables in the database (preop_data and pathology_data and a join table preop_pathology_jt).  The pathology_data has a static list of entries that a user can pick to assign to preop_data.  This relationship needs to be saved into the preop_pathology_jt.

 

I am not getting any errors or exceptions when I try to save this information.  When I save the preop_data everything gets saved in that table.  But nothing is getting written into the join table.

 

 

Here is the object code and mapping.xml snippet.

 

<class name="refobjects.PreOperativeData" identity="id" key-generator="PRE_OP_DATA_SEQ" access="shared">

        <cache-type type="none"/>

        <description>PreOperativeData</description>

        <map-to table="preop_data" />

            <field name="pathologies" type="refobjects.Pathology" collection="collection" direct="false" lazy="false">

            <sql name="pathology_id" many-table="preop_pathology_jt" many-key="preop_data_id"/>

        </field>

</class>

 

<class name=" refobjects.Pathology" identity="id" key-generator="PATHOLOGY_SEQ" access="shared">

        <cache-type type="none"/>

        <description>Pathology</description>

        <map-to table="pathology_data"/>

        <field name="id" type="integer" required="false" direct="false" lazy="false" >

          <sql name="pathology_id" type="integer" dirty="check"/>

        </field>

        <field name="value" type="string" required="false" direct="false" lazy="false">

          <sql name="value" type="char" dirty="check" />

        </field>

</class>

 

public class PreOperativeData {

            private Collection pathologies;

 

            public Collection getPathologies() {

                        return pathologies;

            }

 

            public void setPathologies(Collection pathologies) {

                        this.pathologies = pathologies;

            }

 

            public void addPathologies(Pathology pathology) {

                        pathologies.add(pathology);

            }

 

}

 

 

public class Pathology {

            protected String value;

protected int id;

 

public String getValue() {

return value;

}

 

public void setValue(String value) {

        this.value = value;

}

 

public void setId(int newId) {

        id = newId;

}

 

public int getId() {

        return id;

}

}

 

 

Thanks for your help,

Kiran

Reply via email to