Question

I'm learning to use neo4j, but am a bit confused on its usage. When I'm adding nodes and relationships, I can do it like this:

GraphDatabaseService graphDb = new EmbeddedGraphDatabase("C:/temp/graphdb");
Transaction tx = graphDb.beginTx();
try {
  org.neo4j.graphdb.Node node = graphDb.createNode();
  ...

I could also do it like this:

NeoService neoService = new EmbeddedNeo("C:/temp/graphdb");
Transaction tx = neoService.beginTx();
try {
  org.neo4j.api.core.Node node = neoService.createNode();
  ...

What is the difference here really? Which one should I use? Why are they 2 different mechanisms? Is this just API evolution here? :) I want to use the MetaModel API and it needs a NeoService, so the choice there is clear I guess.

Was it helpful?

Solution

Sorry, you should use the first one, since in the latest 1.0-RC1 the namespace was moved. This is just naming, the semantics are the same. The second example is outdated and should be removed form the official documentation. Where did you find that?

Cheers,

/peter neubauer

OTHER TIPS

You're spot on with the API evolution comment. The old API is NeoService, so you shouldn't use that. Go with your first snippet. For more information on the API change see e.g. the release mail for the latest rc:

http://www.mail-archive.com/user@lists.neo4j.org/msg02378.html

If you use the latest snapshot (0.7-SNAPSHOT) of the meta-model component, you'll find that it uses the latest API. For our 1.0 release (should be out Real Soon Now :), we're going to make non-SNAPSHOT releases of all components that will use the new API.

-EE

And regarding the meta model, please use the meta-model component (now with the maven artifactId: neo4j-meta-model).

I also notice that the component overview http://components.neo4j.org/neo4j-meta-model/ has some invalid example code and descriptions. I'll try to fix that.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top