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

Loading embedded set of documents in OrientDB 3.0.17 TP3 #8903

Closed rafasantodomingo closed 2 years ago

rafasantodomingo commented 5 years ago

OrientDB Version: TP3 OrientDB 3.0.17

Java Version: 1.8.0_111

OS: Windows 7 Enterprise

Expected behavior

Load a property defined as an embedded set of ODocument into a vertex of a class that contains such property in the schema

Actual behavior

Unexpected validation exception on committing to database when the property is added before the vertex has been assigned to the class. It is done correctly when the property is added after the vertex has been assigned to the class

Steps to reproduce

Test 2 throws a validation exception on committing to the database becasue for some reason only the first value in "oDocumentSet" is taken, so the value is treated as a ODocument instead of a ODocumentSet and hence the validation exception!

luigidellaquila commented 5 years ago

Hi @rafasantodomingo

Setting @class as a property is definitely not a good practice and is not the intended way to use the API, I'd strongly suggest you to use the following instead:

Vertex v = graph.addVertex("class:orientClass");

Thanks

Luigi

rafasantodomingo commented 5 years ago

Many thanks Luigi,

The thing is that doesn't seem to work in OrientDB Tinkerpops 3. In fact, we have found two problems:

luigidellaquila commented 5 years ago

Hi @rafasantodomingo

Sorry, my bad, please remove the "class:" from the addVertex():

Vertex v = graph.addVertex("theOrientClass");

The problem with the validation is a known one: OrientDB does data validation at each record save, and TinkerPop implementation performs a save at each operation, also after the addVertex(). If you already know the values for the mandatory properties, you can create the vertex and set them in a single operation:

graph.addVertex(T.label, "theOrientClass", "name", "Foo");

I hope it helps

Thanks

Luigi

rafasantodomingo commented 5 years ago

Thanks again Luigi,

"The problem with the validation is a known one: OrientDB does data validation at each record save, and TinkerPop implementation performs a save at each operation, also after the addVertex()."

Ok, is the idea to change this in the future? As said, in OrientDB 2.2.12 Tinkerpops implementation it didn't happen.

luigidellaquila commented 5 years ago

Hi @rafasantodomingo

Hard to say, it's not in the roadmap now, but we can discuss it

Thanks

Luigi

rafasantodomingo commented 5 years ago

It'd be great if you could have a look at it, because most of the time we don't know all the mandatory values when we create a record. We can of course store the data in memory until we've got all the mandatory values, but it's not the best option in terms of performance - and we'd need to restructure our code, which works fine with ODB 2.2.12

Many thanks, Rafa

luigidellaquila commented 5 years ago

Hi @rafasantodomingo

I'll check it and let you know

Thanks

Luigi