Hello

I am building a prototype with Orient DB, I intent to use Graph model. 
Please see attachment for my object model.
I am able to populate data model and query using graph APIs but not by SQL.

Code snippet for initialization


                         OrientGraphNoTx graph = factory.getNoTx();
OrientVertexType modelType  = graph.createVertexType("Models");
modelType.createProperty("hierarchy", OType.STRING);
modelType.createProperty("name", OType.STRING);
//graph.createKeyIndex("hierarchy",Vertex.class, new Parameter<String, 
String>("class", "Models")); 
graph.createEdgeType("Contains");
graph.createEdgeType("Extends");
graph.createEdgeType("Children");

                        //graph.createKeyIndex("hierarchy",Vertex.class, 
new Parameter<String, String>("class", "Models")); // Is this mandatory to 
run queries ? 
graph.commit();
graph.shutdown();


Code snippet for data population

                       OrientVertex model= txGraph.addVertex(type);
model.setProperty("hierarchy", "my hierarchy", OType.STRING);
model.setProperty("name", "my name" , OType.STRING);

                        OrientVertex connected = 
txGraph.addVertex(txGraph.getVertexType("Models"));  

                        model.addEdge("Containts", connected, "Containts"); 
// another vertex 


// Data is populated, I am able to retrieve a model by following code 
   
                     mymodel =  txGraph.getVertices("Models.hierarchy","my 
hierarchy "); // Works fine.

// but  following code fails 
// I cant figure out the issue. 
              String  myhierarchy="my hierarchy" ;
                    OSQLSynchQuery<ODocument> cmd1 =  new 
OSQLSynchQuery<ODocument>("select  from Models WHERE hierarchy = \"" + 
myhierarchy+ "\")");
    for (Vertex v : (Iterable<Vertex>) txGraph.command(cmd1).execute() )
                      { System.out.println("- vert : "  + v); 
                     }

// the result of txGraph.command(cmd1).execute()  is 
"com.tinkerpop.blueprints.impls.orient.OrientDynaElementIterable@315b0333"
// perhaps query is successful but iterating through it fails

for (Vertex v :  (Iterable<Vertex>) txGraph.command(cmd1).execute() ) {
            System.out.println("- cdsf : " +  v);
}




-- 

--- 
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