What is the difference between GraphDatabaseService or NeoService in neo4j

StackOverflow https://stackoverflow.com/questions/2190369

  •  25-09-2019
  •  | 
  •  

문제

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.

도움이 되었습니까?

해결책

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

다른 팁

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top