OrientDB无法通过direction.OUT获得边缘

时间:2016-12-28 13:24:03

标签: java graph orientdb

我正在尝试识别具有起始顶点和结束顶点的边。

为此,我打电话:

vertexStart.getEdges(Direction.OUT, relationshipId)

似乎总是空的。

获取传入的边缘似乎有效,但我需要两者。

vertexStart.getEdges(Direction.IN, relationshipId)

relationshipId是边缘的标签。

Iterable<Vertex> startNodes = this.getVertexList(storage.getStartNode(), graph);
            Iterable<Vertex> endNodes = this.getVertexList(storage.getEndNode(), graph);

            for (Vertex startNode : startNodes)
            {
                for (Vertex endNode : endNodes)
                {
                    String edgeClass = "class:" + storage.getId();
                    Edge edge = startNode.addEdge(edgeClass, endNode);

                    for (Map.Entry<String, Object> entry : storage.getProperties().entrySet())
                    {
                        edge.setProperty(entry.getKey(), entry.getValue());
                    }
                    edge.setProperty(Constants.TAG_HASH, HashCreator.sha1FromRelationship(storage));
                    edge.setProperty(Constants.TAG_SNAPSHOT_ID, snapshotId);
                }
            }
            graph.commit();

用于创建结构。

1 个答案:

答案 0 :(得分:0)

我试图重现你的问题,它在我的情况下有效。 我创建了这个图

enter image description here

顶点#10:0在输入中有一条边,在输出中有一条边。

我使用了这段代码。

using System;
using System.Data;
using System.Data.OleDb; 
using System.Windows.Forms;

namespace WindowsApplication1
{
    public partial class Form1 : Form
    {
        string connetionString;
        OleDbConnection connection;
        OleDbDataAdapter oledbAdapter;
        OleDbCommandBuilder oledbCmdBuilder;
        DataSet ds = new DataSet();
        DataSet changes;
        int i;
        string Sql;


        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            connetionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Your mdb filename;";
            connection = new OleDbConnection(connetionString);
            Sql = "select * from tblUsers";
            try
            {
                connection.Open();
                oledbAdapter = new OleDbDataAdapter(Sql, connection);
                oledbAdapter.Fill(ds);
                dataGridView1.DataSource = ds.Tables[0];
            }
            catch (Exception ex)
            {
                MessageBox.Show (ex.ToString());
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            try
            {
                oledbCmdBuilder = new OleDbCommandBuilder(oledbAdapter);
                changes = ds.GetChanges();
                if (changes != null)
                {
                    oledbAdapter.Update(ds.Tables[0]);
                }
                ds.AcceptChanges();
                MessageBox.Show("Save changes");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
    }
}

我得到了

enter image description here

希望它有所帮助。