You can use DeleteQuery - try
"context.performNonSelectingQuery(query)". But you need to understand
the consequences - if you already have some of the objects being
deleted previously in your application memory, you'll end up with
inconsistent object graph (db row is deleted, but the corresponding
object is still in memory). In this case my advise is to go with your
second option.
Andrus
On Aug 24, 2004, at 11:20 AM, S e r g i o wrote:
> I want to delete all the objects from the database. I have tried
> something like this:
>
> String likePattern = "%1";
> Expression qual = ExpressionFactory.likeIgnoreCaseExp("nombre",
> likePattern);
> DeleteQuery query = new DeleteQuery(Personas.class, qual);
>
> why can't i do something like "context.performQuery(query);" to
> delete all the rows????
...
> SelectQuery query = new SelectQuery(Personas.class, qual);
> Personas persona=null;
> List result = ctxt.performQuery(query);
> for (int i = 0; i<result.size(); i++)
> {
> persona= (Personas)result.get(i);
> ctxt.deleteObject(persona);
> }
> ctxt.commitChanges();
This archive was generated by hypermail 2.0.0 : Tue Aug 24 2004 - 17:08:14 EDT