db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tak Fujimoto <t-fujim...@beingcorp.co.jp>
Subject Unable to insert data into a table with foreign keys
Date Tue, 13 May 2003 10:40:27 GMT
I am unable insert data into a table which has three foreign references.


This is the part of project-schema.xml which describes the table I am having a trouble with.
**************************************************************************************
  <table name="TELSUPPORT" idMethod="native">
    <column name="TELSUPPORT_ID"      type="INTEGER"  required="true" primaryKey="true"
/>
    <column name="MEMBER_ID"      type="INTEGER"  required="true"  />
    <column name="DATE"    type="DATE"   required="true"  />
    <column name="TIME"    type="TIME"  required="true"  />
    <column name="CUSTOMER_NUM"      type="INTEGER"  default="0" />
    <column name="INQUIRY_ID"      type="INTEGER"  required="true" />
    <column name="SUPPORTRESULT_ID"     type="CHAR" size="1"  required="true" />
    <column name="TELSUPPORT"      type="LONGVARCHAR"  default="" />
    <foreign-key foreignTable="MEMBER"><reference local="MEMBER_ID" foreign="MEMBER_ID"
/></foreign-key>
    <foreign-key foreignTable="INQUIRY"><reference local="INQUIRY_ID" foreign="INQUIRY_ID"
/></foreign-key>
    <foreign-key foreignTable="SUPPORTRESULT">
	<reference local="SUPPORTRESULT_ID" foreign="SUPPORTRESULT_ID" /></foreign-key>
  </table>

  <table name="MEMBER" idMethod="native">
    <column name="MEMBER_ID"      type="INTEGER"  required="true"  primaryKey="true" />
    --------------------------------------------------------
  </table>

  <table name="INQUIRY">
    <column name="INQUIRY_ID"      type="INTEGER"  required="true"  primaryKey="true" />
    --------------------------------------------------------
  </table>

  <table name="SUPPORTRESULT">
    <column name="SUPPORTRESULT_ID"      type="CHAR" size="1" required="true"  primaryKey="true"
/>
    --------------------------------------------------------
  </table>
**************************************************************************************

Now, this is a part of the source which I use Torque with struts.

public ActionForward execute ( ActionMapping mapping,
            ActionForm form,
            HttpServletRequest request,
            HttpServletResponse response) {

	Integer memberId = (Integer)session.getAttribute("memberId");
	MainForm mainForm = (MainForm)form;

            Member member = new Member();
            member.setMemberId(memberId.intValue());
            Inquiry inquiry = new Inquiry();
            inquiry.setInquiryId(mainForm.getFormInquiryId());
            Supportresult supportresult = new Supportresult();
            supportresult.setSupportresultId(mainForm.getFormSupportresultId());

            Telsupport newTelsupport = new Telsupport();
            newTelsupport.setMemberId(member.getMemberId());
            newTelsupport.setDate(sqlDate);
            newTelsupport.setTime(sqlTime);
            newTelsupport.setCustomerNum( mainForm.getFormCustomerNum());
            newTelsupport.setInquiryId(inquiry.getInquiryId());
            newTelsupport.setSupportresultId(supportresult.getSupportresultId());
            newTelsupport.setTelsupport( mainForm.getFormTelsupport());
            newTelsupport.save();

return (mapping.findForward("success"));
}

**************************************************************************************

[setup]
jakarta-struts-1.1-b3
jakarta-tomcat-4.0.6
torque-3.0
Red Hat Linux release 7.1 (Seawolf)
apache_1.3.26
mod_jk-1.3-noeapi.so

I refered to http://db.apache.org/torque/tutorial/step4.html and 
I am trying to inserting the foreign-keys manually.

Please give me any advice, suggestion on what I should do if you have time.

Mime
View raw message