Ivan ...

The problem that you're having is one that I had as well. The problem is
that when you call getProperty() on an embedded set or embedded list,
you're getting back a Java collection object (either a HashSet or
ArrayList), but it is not monitored by Orient in any way.  You're making
changes to that object, but Orient isn't aware of the changes.  You need to
do the following instead:

gremlin> array = g.e("#13:0").getProperty("array")
==>true
gremlin> array.push("two")
==>true
gremlin> g.e("#13:0").setProperty("array", array )
==>true
gremlin> g.commit()


By using setProperty(), you're telling Orient to re-scan the array and save
the changes.

- Craig -

On Tue, Mar 24, 2015 at 9:06 AM, Ivan Plaza <[email protected]> wrote:

> Hi
>
> I'm having an issue committing changes to an array field with gremlin and
> orientdb. It seems updates to embedded lists are ignored.
>
> I have an edge that contains an array. If I push a new value to the array
> and commit the change, the new value does not show in the database.
>
> However, if I push a new value to the array and also set another field,
> then commit, the array values appear.
>
> Here's the sequence:
>
> (create 2 vertices)
> gremlin> v1 = g.addVertex();
> ==>v[#-1:-2]
> gremlin> v2 = g.addVertex();
> ==>v[#-1:-3]
> gremlin> g.commit()
> ==>null
>
> (create the edge between two vertices with array)
> g.addEdge(v1,v2,"Friend",["array":["one"]])
> gremlin> g.e("#13:0")
> ==>e[#13:0][#9:3-Friend->#9:4]
>
> (now push a new value to the array and commit the change)
> gremlin> g.e("#13:0").getProperty("array").push("two")
> ==>true
> gremlin> g.e("#13:0").getProperty("array")
> ==>one
> ==>two
> gremlin> g.commit()
>
> (now reconnect to see if the update was saved)
> gremlin> g = new
> OrientGraph("remote:/orientdb-community-2.0.5/databases/test");
> gremlin>
> g.e("#13:0").map
>
> ==>{array=[one]}
> (nope, array only has one value)
>
> (now lets try updating the array and another field)
> gremlin>
> g.e("#13:0").getProperty("array").push("two")
>
> ==>true
> gremlin> g.e("#13:0").map
> ==>{array=[one, two]}
> gremlin> g.e("#13:0").delta=1
> ==>1
> gremlin>
> g.commit()
>
> ==>null
>
> (now reconnect )
> gremlin> g = new
> OrientGraph("remote:/orientdb-community-2.0.5/databases/test");
>
> ==>orientgraph[remote:/Users/yvan/dev/orientdb-community-2.0.5/databases/test]
> gremlin>
> g.e("#13:0").map
>
> ==>{array=[one, two], delta=1}
> (yep, we got two values now but we were forced to set another field)
>
> Any ideas ??
> I posted this in both orientdb and gremlin groups as I dont know where the
> issue lies
> Gremlin Version: 2.6.0
> OrientDB Version: 2.0.5
>
>  --
>
> ---
> You received this message because you are subscribed to the Google Groups
> "OrientDB" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"OrientDB" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to