开发者

What is the difference between GraphDatabaseService or NeoService in neo4j

开发者 https://www.devze.com 2022-12-19 04:30 出处:网络
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:

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消