Thank you for the great response. I will try the save() approach. It would
probably perform better than setting the map again. I was hoping there was
a way to do this using just the graph API but this will do for now.
A small issue with your code: the Vertex class doesn't have a getRecord()
method. You have to cast it to an OrientVertex.
Curtis
On Monday, September 14, 2015 at 12:21:12 PM UTC-6, Jan Plaček wrote:
>
> "Going into the orient-specific API and getting the underlying record
> works but changing the map on the record doesn't save the changes at
> transaction's end."
>
> That is interesting, at first I thought that the returned map itself
> probably isn't "managed", that it is a copy of some internal LINKMAP
> strucutre ... this way it would make sense that changes are not propagated
> and re-seting the field with updated map is necessary.
> However you will actually obtain instance of ORecordLazyMap:
>
> Lazy implementation of LinkedHashMap. It's bound to a source ORecord
> object to keep track of changes. This avoid to call the makeDirty() by hand
> when the map is changed.
>
> So I tested this and it's all true, the document is dirty, but changes are
> not commited. Why?
>
> WHEN WORKING WITH DOCUMENT API YOU HAVE TO EXPLICITELY CALL
> ODocument.save()
>
> Here is an example:
>
> Vertex v = graph.getVertex("#x:y");
> Map<String, ORecord> map = v.getRecord().field("linkMap", OType.LINKMAP);
> map.remove("v1");
> v.getRecord().save();
> graph.shutdown(); // or graph.commit();
>
> UPDATE:
> I updated the example so that map entry is a type of ORecord intead of
> Vertex (ODocument is also an option in our case)
> Even though the example worked with Vertex, it will produce exception
> later, when accessing that entry.
>
--
---
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.