tags:

views:

204

answers:

3

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.

+3  A: 

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

Thanks for the answer! I'm trying to use the MetaModel and it needs a NeoService in the MetaModelImpl constuctor.
Kaitsu
+2  A: 

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/[email protected]/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

emileifrem
It seems that meta-model component 0.7-SNAPSHOT still uses the old Neoservice. So, I cannot use the new API in neo4j-kernel 1.0-rc (that has GraphDataService). In the meta-model trunk, this seems to be fixed, though :)
Kaitsu
+2  A: 

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.