Hello,
Do not use DeleteQuery as it won't update your object graph. This is not a
bug - DeleteQuery (and its friends - Insert and Update) work with DB
directly. For the curious, they were used internally by Cayenne in the
past (before we switched to BatchQuery). While DeleteQuery still works
performing its intended operation - deleting rows from DB, I am
considering whether we should get rid of it all together to eliminate
confusion.
> Finally, the expected behaviour was after selecting the AddPers object
> with a selectQuery and the same expresions and deleting with
> dataContext.deleteObject(..);
Deleting an object is the correct way - you should think in terms of
objects and go with the standard Cayenne procedure. Also you can get rid
of AddPers class at all (if it is just a join without fields of its own)
and map n:m as a flattened relationship to be able to do something like
person.removeFormAddresses(address).
Andrus
>
> i have a n:m relation between Address & Person tables mapped with
> AddPers table.
>
> I wanted to delete the relation between a person and one address using a
> deletequery.
> So i did somethis like
> Expression add = ExpressionFactory.matchExp("toAddress", a_address);
> Expression pers = ExpressionFactory.matchExp("toPerson", a_person);
> DeleteQuery delq = new DeleteQuery(AddPers.class, add.adnExp(pers));
> dataContext.performNonSelectingQueyr(delq);
> dataContect.commitChanges();
>
> The object Addpers was delete properly but at the nezt fetch of Person
> it still gave me the Address i just deleted ! So i used
> dataContext.refetchObject(person) but with no effect.
>
> the delete action between Addpers and address is nullfy and for person
> the same.
>
> Finally, the expected behaviour was after selecting the AddPers object
> with a selectQuery and the same expresions and deleting with
> dataContext.deleteObject(..);
>
> It is a bug or i missed something in my code?
This archive was generated by hypermail 2.0.0 : Wed Jan 26 2005 - 09:14:32 EST