Comments (7)
you don't provide much context so I can only guess, but let me guess that you're trying to persist one of your own classes via a remote connection to orientdb? that wouldn't work because orient doesn't know your classes
from orientdb-gremlin.
Yup, that's the situation, eventually the ODocument sent off for saving contains an ODocumentEntry with the raw instance of my domain class. I think it should be also wrapped into an ODocument.
Would it be a big deal to wrap embedded classes in the orientdb-gremlin driver?
from orientdb-gremlin.
maybe i wasn't clear enough - you cannot send your own classes via a remote connection to orientdb. you need to transform them into a vertex first. gremlin-scala e.g. has a macro that does that job for you: https://github.com/mpollmeier/gremlin-scala/#mapping-vertices-fromto-case-classes
from orientdb-gremlin.
Hi,
sorry for not being mistaken, but I was under the impression that this would work:
import org.apache.tinkerpop.gremlin.orientdb.OrientGraphFactory
import org.scalatest.{Matchers, WordSpec}
import gremlin.scala._
import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph
class SerializeNestedSpec extends WordSpec with Matchers {
"Classes with Nested members" must {
"be correctly serialized" in new Fixture {
val foo = Foo("a string")
val bar = Bar("another string", foo)
val vertex = graph + bar
val bar1 = vertex.toCC[Bar]
bar1.should(equal(bar))
}
}
case class Foo(string: String)
case class Bar(string: String, foo: Foo)
trait Fixture {
// val graph = TinkerGraph.open.asScala
val graph = new OrientGraphFactory(s"memory:test-${math.random}").getNoTx().asScala
}
}
The problem is that the macro doesn't recur. If you step into the addVertex it'll eventually call org.apache.tinkerpop.gremlin.orientdb.OrientElement#property(java.lang.Object...)
with a Foo object in the properties. The TinkerGraph implementation doesn't mind, but Orient does as it expects nested documents to be wrapped in ODocuments, not ODocumentEntries.
I don't know if it would be a good approach but the Orient driver (in com.orientechnologies.orient.core.record.impl.ODocument#field(java.lang.String, java.lang.Object
, which is eventually called) supports nested fields using .
interpolation: fromCC could flatten the foo instance fiends in bar as a foo.string, while toCC would de-interpolate the fields and rebuild the objects accordingly. I think this could also help the Neo4J backend, since it doesn't support nested documents at all!
from orientdb-gremlin.
This is general issue with scala classes/types. Funny part is, this works for memory storage, whereas remote doesn't.
from orientdb-gremlin.
I guess it's because when running "in memory" the JVM knows how to serialize the CCs because they're in the classpath.
from orientdb-gremlin.
exactly - the in memory instance knows all your classes, but in production you're unlikely to run it this way. and yeah, quite possible that the macro doesn't support nesting.
from orientdb-gremlin.
Related Issues (20)
- Upgrade to TinkerPop 3.4.x for ODB 3.1.x
- How to get vertex class name with gremlin console? HOT 1
- Groovy version conflect with gremlin server HOT 2
- gremlin-python tutorial test_000.py fails
- Queries with two or more parameters don't work. HOT 7
- Inconsistent transaction beheviour w/remote: HOT 2
- Cannot create property-index on graph loaded via gremlin API HOT 2
- java.lang.IllegalArgumentException: rawElement must not be null! HOT 12
- Maven Group ID in pom.xml is not the official one? HOT 3
- First run problems on OSX (3.1.0) HOT 14
- gremlin traversalsource io step not supported
- gremlin.sh exits immediately
- java.lang.NegativeArraySizeException on g.V().drop()
- error on installing orientdb plugin into gremlin console HOT 1
- How to use GraphComputer with gremlinpython or java api to make some computation like pageRank algorithme ?
- [rl-vulnerability_alerts-1] Violation against OSS Rules of Play HOT 1
- [rl-reuse_tool-2] Violation against OSS Rules of Play HOT 1
- [rl-reuse_tool-1] Violation against OSS Rules of Play HOT 1
- [rl-reuse_tool-3] Violation against OSS Rules of Play HOT 1
- [rl-reuse_tool-4] Violation against OSS Rules of Play HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from orientdb-gremlin.