Hello Amando,
What I usually do is retrieving the object using a SelectQuery or by getting
the object using the ObjectId, then I update the object using its set
methods and do a myDataContext.commitChanges().
So, for example:
[..]
// Get the Object
SelectQuery qry
= new SelectQuery(Monkey.class);
Expression qualifier
= ExpressionFactory.binaryPathExp(Expression.EQUAL_TO, "name",
"myMonkeyName");
List monkeys = myDataContext.performQuery(qry);
// Assume we want the first one, or name is unique key, and the query always
returns something...
Monkey monkey = (Monkey) monkeys.get(0);
// Update the object
monkey.setName("myNewMonkeyName");
monkey.setAge(15);
monkey.setDateOfBirth(1973);
myDataContext.commitChanges();
[...]
It could be that there is a more efficient way, but this seems to work fine
:-).
Hope this helps, Laszlo
>From: amando.net..aixaseguros.com.br
>To: cayenne-use..bjectstyle.org
>Subject: UpdateQuery
>Date: Mon, 28 Jul 2003 14:12:00 -0300
>
>----- Repassado por Amando dos Santos Neto/MATRIZ/SASSE em 07/28/2003
>02:14 PM -----
>
>
>
>
>
>
>
>Amando dos Santos Neto
>07/28/2003 02:08 PM
>
>
> Para: cayenne-use..bjectstyle.org
> cc:
> Assunto: UpdateQuery
>
>
>----- Repassado por Amando dos Santos Neto/MATRIZ/SASSE em 07/28/2003
>02:10 PM -----
>
>
>
>
>
>
>
>Amando dos Santos Neto
>07/28/2003 02:05 PM
>
>
> Para: cayenne-use..bjectstyle.org
> cc:
> Assunto: UpdateQuery
>
>Hello.
>
>I am trying to execute an update using the UpdateQuery, but nothing
>happens.
>No errors messages are throwing and the data is not updated.
>
>
>Here is my code.
>Expression exp = ExpressionFactory.binaryDbPathExp(
> Expression.EQUAL_TO,
> "login",
> login
> );
>
> UpdateQuery upDate = new
>UpdateQuery(TblUsuario.class,exp);
> upDate.addUpdAttribute("login", "paulo");
> upDate.setLoggingLevel( Level.WARN );
> ctxt.commitChanges(Level.FATAL);
>
>Is there anyone that could help me out how to execute an update?
>
>Thanks,
>Amando
>
_________________________________________________________________
MSN 8 with e-mail virus protection service: 2 months FREE*
http://join.msn.com/?page=features/virus
This archive was generated by hypermail 2.0.0 : Mon Jul 28 2003 - 16:14:17 EDT