I have an OrientDB database with a class that has an EMBEDDEDSET
/EMBEDDEDLIST
field, and I need to update that field every time I change something, like a record log.
I'm using a normal insert
:
insert into order set ..., logLikeField = "A new value"
By doing this the new value replaces the old ones, and what I need is to add it to the list but I can't find out how to do that within the docs.
Right now I'm taking the list out and adding the new value and replacing the old list (first a select
then the update
), but I don't like it, and I need to do it with the least possible queries.
By the way i'm using Java (w/o JDBC).
[EDIT]
As suggested in the answer below i used:
insert into order add logLikeField = "A new value"
It worked fine in the OrientDB Studio, but it does nothing when i call it from my program.
This is the code (language spanish):
db.command(command("update ordenes set fecha = ?, numero = ?, producto = ? where @rid = " + orden.id)).execute(orden.fecha, orden.numero, orden.producto);
db.command(command("update ordenes add registro = ? where @rid = " + orden.id)).execute(registro);
I wanted a one line solution but as long as it is not a select it's good.
This is the command method:
public OCommandSQL command(sql){
return new OCommandSQL(sql);
}
the first command does the job correctly but with the other one I get nothing, not even an exception.
What's wrong with my approach? could it be a bug?
OrientDB 1.3.0 - Java 1.7.0 - Windows 7 64
update order add logLikeField = "A new value"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With