orientdb icon indicating copy to clipboard operation
orientdb copied to clipboard

bug of setProperty("abc", ArrayList<Object> ) of OrientGraph

Open ninesunqian opened this issue 13 years ago • 4 comments

I using a ArrayList to save the child-edge's id, the arraylist is saved the parent vertex by set setProperty. But when I arraylist.get(0), the return value is a Edge not the id of the Edge.

the code:

public EdgeVertex[] getChildren(Vertex parent)
{
    ArrayList<Object> edgeIDsToChildren = getEdgeIDsToChildren(parent);
    if (edgeIDsToChildren == null)
    {
        return null;
    }
    else
    {
        EdgeVertex [] children = new EdgeVertex[edgeIDsToChildren.size()];
        System.out.println (edgeIDsToChildren);
        System.out.println (edgeIDsToChildren.get(0));
        System.out.println (edgeIDsToChildren);
        System.out.println (edgeIDsToChildren.get(1));
        for (int i=0; i<children.length; i++)
        {
            Edge edgeToChild = getEdge(edgeIDsToChildren.get(i));
            Vertex child = getChildOnEdge(edgeToChild);
            children [i] = new EdgeVertex(edgeToChild, child);
        }

        return children;
    }
}  

the printed string is

[#9:0, #9:5, #9:10] E#9:0{out:#8:0,in:#8:1,label:null,_edgeType:0} v1 [E#9:0{out:#8:0,in:#8:1,label:null,_edgeType:0} v1, #9:5, #9:10] E#9:5{out:#8:0,in:#8:5,label:null,_edgeType:0} v1

ninesunqian avatar Apr 10 '13 12:04 ninesunqian

This is not a bug but a feature: the RID are lazily loaded. To avoid this you can set disable this behavior by:

edgeIDsToChildren.setAutoConvertToRecord(false);

lvca avatar Apr 10 '13 21:04 lvca

but when I use blueprints, I don't want to care the details of Orientdb. I don't know that ArrayList is changed to a OrientLazyList(Sorry I forgot its true name). And I have two questions: 1st: When I setProperty a java array or a LinkedList, will It be changed to a OrientLazyList ? 2nd: Can I close the feature, in blueprints OrientGraph method ?

ninesunqian avatar Apr 11 '13 06:04 ninesunqian

You can disable lazy loading only by such way. Or you could store not the RID but a string. In this way the lazy loading doesn't work.

lvca avatar Apr 11 '13 12:04 lvca

Thanks very much! I think setAutoConvertToRecord(false) is better

ninesunqian avatar Apr 12 '13 03:04 ninesunqian