Re: UpdateQuery

From: Holger Hoffstätte (holge..izards.de)
Date: Tue Jul 29 2003 - 11:18:49 EDT


amando.net..aixaseguros.com.br wrote:

> I am trying to execute an update using the UpdateQuery, but nothing
> happens. No errors messages are throwing and the data is not updated.

Well, you got it almost right!

> Expression exp = ExpressionFactory.binaryDbPathExp(
> Expression.EQUAL_TO, "login", login);

The first "login" must be the physical attribute in the table, i.e. the
DbAttribute. You could also use the ObjAttribute name with a
binary(Path)Exp.

> upDate.addUpdAttribute("login", "paulo");

Here "login" also needs to be the DbAtrribute name; unfortunately the
ObjAttribute name won't work. :(

> ctxt.commitChanges(Level.FATAL);

This should be something like:

    DefaultOperationObserver observer = new DefaultOperationObserver();
    ctxt.performQuery(q, observer);
    if (observer.hasExceptions())
    {
        // handle error
        log.debug("Error: " + observer.getQueryExceptions());
    }

Directly executing queries basically works (and is very useful, e.g. for
mass updates) but is IMHO still too confusing and inconsistent; this needs
to be addressed for 1.1.

Holger



This archive was generated by hypermail 2.0.0 : Tue Jul 29 2003 - 11:15:21 EDT