You can delete a record in exactly the same way you select it. The only
difference is that you use a DeleteQuery instead of a SelectQuery object.
DeleteQuery dq = new DeletQuery(x.class);
dq.setQualifier(...);
// more qualifiers if needed
context.performNonSelectingQuery(dq);
Joe
On 6/6/05 4:11 PM, "Dhruti Ramani" <dhrutiraman..ahoo.com> wrote:
>
> Thanks, I have read about that. Thats what I was trying to do. I was trying to
> get object from database and then use deleteObject method. But my query
> depends on two tables and I dont know how to get hold of particular object. If
> I use SQLTemplate it return results in turms of Map, but I need to get Object
> to delete it.
>
> Is there any other way to do this?
> Thanks,
> Denna
> Andrus Adamchik <andru..bjectstyle.org> wrote:
>> Denna,
>>
>> You better avoid deleting data from DB directly. You may end up with
>> an inconsistent object graph ... and generally if you work in the ORM
>> object space, why bother with SQL.
>>
>> So just get a hold of an object in question and then do:
>>
>> dataContext.deleteObject(object);
>> dataContext.commitChanges()
>>
>> Andrus
>>
>>
>> On Jun 6, 2005, at 11:51 AM, Dhruti Ramani wrote:
>>> > Hi,
>>> >
>>> > I have to remove a DoListItem whose type is 'xyz' for particular
>>> > Deal (so basically query uses two tables). How do I delete that
>>> > particular object? I was trying to use SQLTemplate but it returns
>>> > Map so i can not bind that to particular object.
>>> >
>>> > Any ideal?
>>> > Thanks,
>>> > Denna
>
>
> Discover Yahoo!
> Have fun online with music videos, cool games, IM more. Check it out!
> <http://us.rd.yahoo.com/evt=32660/*http://discover.yahoo.com/online.html>
This archive was generated by hypermail 2.0.0 : Mon Jun 06 2005 - 16:16:33 EDT