简体   繁体   中英

OrientDB graph: How to use Java API to create a new Record?

I know how to create an Record with the Web GUI of OrientDB. How am I able to create a New Record with the Java API? This is what I have done with the GUI so far.

You can download the full version of the picture here

在此输入图像描述

This is my code so far but my knowledge is to low. I just know how to handle Vertex.

    OrientGraphFactory ogf = new OrientGraphFactory(
            "plocal:/home/paulkalkbrenner/Dokumente/odb/databases/ConnectER", "admin", "admin");
    OrientGraph og = ogf.getTx();

    try {
        System.out.println("message bevor vertex");

        Vertex relation0_vertex = og.addVertex(null);
        relation0_vertex.setProperty("Lastname", rel0);

        //System.out.println("Features = " + og.getFeatures());
        for (Vertex v : og.getVertices()) {
            System.out.println(v.getProperty("Lastname"));
        }
    }
    finally {
        og.shutdown();
    }

try this code

OrientGraphFactory ogf = new OrientGraphFactory(
        "plocal:/home/paulkalkbrenner/Dokumente/odb/databases/ConnectER", "admin", "admin");
    OrientGraph og = ogf.getTx();

    OClass cl=og.createVertexType("Person", "V");
    cl.createProperty("LastName", OType.STRING);

    OrientVertex v1=og.addVertex("class:Person");
    v1.setProperties("Lastname","Alessandro");

    for (Vertex v : og.getVertices()) {
        System.out.println(v.getProperty("Lastname"));
    }

    og.shutdown();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM