db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Eric Emminger <e...@ericemminger.com>
Subject Re: insert data into a table with foreign key
Date Wed, 16 Apr 2003 16:17:41 GMT
Tak

> I am unable insert data into a table which has two foreign references.
> 
> 
> This is the part of project-schema.xml which describes the table I am having a trouble
with.
> *****************************************************************************************
> <table name="TELSUPPORT">
>   <column name="TELSUPPORT_ID"  type="INTEGER"  required="true" autoIncrement="true"
>     primaryKey="true" />
>   <column name="MEMBER_ID"      type="INTEGER"  required="true"  />
>   <column name="DATE"    type="DATE"  default="now" required="true"  />
>   <column name="TIME"    type="TIME" default="now" 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="VARCHAR" size="10000" 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>
> *****************************************************************************************
> 
> Now, I have tried this script below but it did not insert data.
> 
> 	Telsupport newTelsupport = new Telsupport();
> 	newTelsupport.setMemberId(3);
> 	newTelsupport.setCustomerNum(1234);
> 	newTelsupport.setInquiryId(1);
> 	newTelsupport.setSupportresultId("1");
> 	newTelsupport.setTelsupport("test");
> 	newTelsupport.save();

You didn't list which database you're using. If your database supports 
foreign-key constraints (referential integrity), the insert will fail 
unless the foreign keys you specify exist. Do the above foreign-key 
values exist in the database? Torque does work with multiple foreign keys.

> Strange thing is that there is absolutely no error.
> I have seen no error when I compile the class file nor in the logs of TOMCAT.
> I have checked BaseTelsupport.java and these methods should be working.

As far as I know, these kinds of errors show up in your 
Torque-configured logs, not a general Tomcat log. Check your config to 
find the logs.

> [environment]
> 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

Eric


Mime
View raw message