Gareth's method is correct.  However, I was looking at the code
and wondering if there is not a bug here.  The main question 
IMHO is: 

What is the specific purpose of the the doDelete( SomeTable obj )
method?

Is it intended to only delete a single records or is it supposed
to allow for deleting multiple records identified by a template 
object?  E.g., should code like:

   SomeTable obj = new SomeTable();
   obj.setCategory(value);
   obj.setSubCategory(value2);
   SomeTablePeer.doDelete(obj);

1) Delete only records that have Category=value, subcategory 
= value2, and ALL other fields = null or default values.

or.

2) Delete all records that had category=value and subcategory 
= value2, regardless of other field values.

In either case, there probably should be a test to see if the 
object has a primary key defined and then do a delete by PK
call.

If the intent is to allow "template" deletes, the code here is 
wrong because it does not check for null values, which should
be excluded from the criteria unless the object is ! isNew().

If the intent is to allow only for deletion of records that
are "exact" matches. Then the code is OK except for the issue
of some DB's not allowing = for long fields (use like in 
this case?).  However, if the test for a PK is added, then
this only occures in the limited case of tables without a PK
(which is highly recommended in any good DB design).

Anyway, if we can come to a concensus on the purpose of this
method, I'll put in the Issue and a patch for the Template
file.



> -----Original Message-----
> From: Gareth Boden [mailto:[EMAIL PROTECTED] 
> Sent: Monday, February 13, 2006 6:46 AM
> To: torque-user@db.apache.org
> Subject: Re: Problems with CLOB and Peer.doDelete(obj)
> 
> 
> > I got a problem with torque3.1.1 when deleting and object using its
> > peer. I think the problem is with the definition of the  
> > buildCriteria method.
> 
> You want to just delete it with the primary key, not the whole object:
>       SomeTablePeer.doDelete(((SomeTable) obj).getPrimaryKey());
> 
> Gareth
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 

Duke CE Privacy Statement
Please be advised that this e-mail and any files transmitted with it are 
confidential communication or may otherwise be privileged or confidential and 
are intended solely for the individual or entity to whom they are addressed.  
If you are not the intended recipient you may not rely on the contents of this 
email or any attachments, and we ask that you  please not read, copy or 
retransmit this communication, but reply to the sender and destroy the email, 
its contents, and all copies thereof immediately.  Any unauthorized 
dissemination, distribution or copying of this communication is strictly 
prohibited.



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to