orientechnologies / orientdb

OrientDB is the most versatile DBMS supporting Graph, Document, Reactive, Full-Text and Geospatial models in one Multi-Model product. OrientDB can run distributed (Multi-Master), supports SQL, ACID Transactions, Full-Text indexing and Reactive Queries.
https://orientdb.dev
Apache License 2.0
4.72k stars 870 forks source link

Graph API: Adding verticies works only with "class:" notation and adding edges works only without "class:" notation #3692

Closed zifnab87 closed 9 years ago

zifnab87 commented 9 years ago

Hi, In the documentation it is stated that we have to use class:className when we are creating both Vertices and Edges: http://www.orientechnologies.com/docs/2.0/orientdb.wiki/Graph-Database-Tinkerpop.html#create-element-and-properties-all-together http://www.orientechnologies.com/docs/2.0/orientdb.wiki/Graph-Database-Tinkerpop.html#transactions

I found that for a vertex this works

Vertex vertex = graph.addVertex("class:TestVertexClass");

but this doesn't

Vertex vertex = graph.addVertex("TestVertexClass");

and for an edge:

this works:

vertex.addEdge("TestEdgeClass",vertex2);

and this doesn't

vertex.addEdge("class:TestEdgeClass",vertex2);

When I add Edge with "class:" notation I get this warning and this exception

WARNING: Requested command 'Committing the active transaction to create the new type 'class%3ATestEdgeClass' as subclass of 'E'. The transaction will be reopen right after that. To avoid this behavior create the classes outside the transaction' must be executed outside active transaction: the transaction will be committed and reopen right after it. To avoid this behavior execute it outside a transaction Exception in thread "main" com.orientechnologies.orient.core.exception.OSchemaException: Invalid class name found. Character '%' cannot be used in class name

while when I add a Vertex with no "class:" notation I don't get a Warning and it is being added in V class

I am using

       <dependency>
          <groupId>com.tinkerpop.blueprints</groupId>
          <artifactId>blueprints-core</artifactId>
          <version>2.6.0</version>
          <type>bundle</type>
        </dependency>
      <dependency>
          <groupId>com.orientechnologies</groupId>
          <artifactId>orientdb-graphdb</artifactId>
          <version>2.1-SNAPSHOT</version>
          <type>bundle</type>
        </dependency>
     <dependency>
          <groupId>com.orientechnologies</groupId>
          <artifactId>orientdb-core</artifactId>
          <version>2.1-SNAPSHOT</version>
          <type>bundle</type>
        </dependency>

Could it be implemented in souch a way so that it is consistent for both Verticies and Edges?

Also it seems that addEdge with properties altogether ( in the mentioned documentation example) is not supported anymore since blueprints doesn't provide it? The documentation needs an update if that is the case.

person1.addEdge("class:Friend", person2, null, null, "since", "2013-07-30");

Thank you!

zifnab87 commented 9 years ago

@lvca I updated the description because I thought class: notation support was forgotten for verticies but it seems that it is mandatory for them, while cannot be used with edges. Thanks

zifnab87 commented 9 years ago

just making sure that this didn't slip by. Thanks

lvca commented 9 years ago

@zifnab87 I'd mark this issue as invalid, because the semantic of addVertex() and addEdge() is different. Check Blueprints JavaDocs. in addVertex the first param is the ID, in addEdge is the label. So the current behavior is correct.

About "addEdge with properties altogether" is not Blueprints, so you should call as OrientVertex, not Vertex.