I have the same setup:
<table name="TABLEA">
<column name="tablea_id" required="true" primaryKey="true" type
="INTEGER" />
....
</table>
<table name="TABLEB">
<column name="tablea_id" required="true" type="INTEGER"/>
<column name="tablec_id" required="true" type="INTEGER"/>
<foreign-key foreignTable="TABLEA">
<reference local="tablea_id" foreign="tablea_id"/>
</foreign-key>
<foreign-key foreignTable="TABLEC">
<reference local="tablec_id" foreign="tablec_id"/>
</foreign-key>
</table>
Note that this join table had no primary key (tho at one point I did denote
both of them as primaryKey="true" to try for a composite key but I still
got the same error). Trying something like you suggested, passing TABLEA_ID
to the doDelete() method in TABLEBPeer gave me an error saying the KeyDef
was improperly specified. I took this to mean one of two things, either all
tables, regardless, have to have primary keys or that one could only delete
an object by primary key. I changed my TABLEB definition to include a PK:
<column name="tableb_id" required="true" primaryKey="true" type="INTEGER"/>
and my business object to retrieve the FK'd child objects and loop through
them one by one. It looks like, from what you're saying, that as long as I
have a primary key in the join table I can safely feed doDelete() an FK ...
yes? Will try that, but the inclusion of a primary key into every join
table is unexpected (and could use some documentation :P).
Thanks ...
-j
Steve Hansen
<steve.hansen@sin To: Turbine Torque Users List
ex.com>
<[EMAIL PROTECTED]>
cc:
12/11/2002 01:07 Subject: Re: Deleting by pk
PM
Please respond to
"Turbine Torque
Users List"
I'm not sure what trouble you're having with delete...
I have code that seems to work fine doing the following.
Table A, 1 -------- Many Table B
Criteria crit = new Criteria();
crit.add(BPeer.A_FOREIGN_KEY, aFKey);
B.doDelete(crit);
This will delete all related rows in Table B given a aFKey value.
If your having other issues post your error messages and relevant
section of myproject-schema.xml
Steve
On Tue, 2002-12-10 at 20:10, [EMAIL PROTECTED] wrote:
>
> So ... I've read the threads in the archives but to make sure ... is the
> only way to delete an object by using it's Peer.doDelete() method and
> passing a Criteria object that specifies the primary key? This means that
> even join tables now have to have primary keys of their own ... and that
I
> have to constantly look up primary keys using normal Criteria objects,
form
> Lists and iterate over them doDelete()'ing on each one. Or am I missing
> something obvious?
>
> Please say yes. :)
> -j
>
>
>
> --
> To unsubscribe, e-mail: <
mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail: <
mailto:[EMAIL PROTECTED]>
>
>
--
To unsubscribe, e-mail: <
mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <
mailto:[EMAIL PROTECTED]>
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>