Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Neo4j and ORM (Hibernate)

I've been using RDBMSes since college and am really struggling with the underlying concepts of NoSQL databases...but I think their concept is really cool.

I believe I understand the following (please correct me if I'm wrong, because these play into my question here!):

  • NoSQL is not some formal specification; it is a concept underlying a new "breed" of databases that are not relational and do not use SQL
  • As such, each NoSQL system is different (for instance, MongoDB is JSON-centric)

If these are true, then let us redirect our attention to Neo4j, a "graph-based" database.

After perusing the site and the PDF, it seems like Neo4j is not only a database, but it also provides a Java API that essentially replaces the need for traditional ORM tools like Hibernate.

So, my final question is actually a request for clarification/confirmation of that last assertion, specifically:

  • Is it true that if my backend is entirely Neo4j-based, that I would have no need for Hibernate (which is my usual ORM)? Are these two APIs mutually-exclusive, or is there some way to benefit between using both of them?

Thanks in advance!

like image 430
IAmYourFaja Avatar asked Feb 08 '12 15:02

IAmYourFaja


People also ask

What are the weaknesses of Neo4j?

Additionally, Neo4j has scalability weaknesses related to scaling writes, hence if your application is expected to have very large write throughputs, then Neo4j is not for you.

Can I use hibernate with MongoDB?

How to use Hibernate OGM with MongoDB? To get started with Hibernate MongoDB, you first need to build the OGM from Source via GitBug. To include OGM in your Hibernate MongoDB project, just include one more dependency in your list of dependencies. Next, to define the persistence unit, create a META-INF/persistence.

Is Neo4j OLTP or OLAP?

Titan, OrientDB, Neo4j are examples of OLTP tools. OLAP systems instead perform complex analysis (e.g. graph traversal, data aggregation) which involve extremely large graphs. Spark GraphX, Apache Giraph and SparkGraphComputer are examples of OLAP tools.

Does Neo4j support Gql?

Graph Query Language (GQL) Is Now a Global Standards Project. Platform Overview → Neo4j graph technology products help the world make sense of data.


2 Answers

I've been using RDBMSes since college and am really struggling with the underlying concepts of NoSQL databases...but I think their concept is really cool.

A graph database like Neo4j expresses a domain in terms of vertices connected to other vertices with edges. An edge contains its start and end vertex. Each vertex and edge can have a map of properties, key-value pairs that can be used to store additional information about the vertices and edges. You can, of course, extend this with your own domain, but things are simple to start out.

To see these concepts in action, I recommend the Getting Started Guide for Gremlin. Gremlin is a domain-specific language for traversing graphs that works with Neo4j and several other graph databases. Gremlin is to a graph database what SQL is to a relational database.

I can't recommend Gremlin strongly enough while you're learning about graphs. In just a few minutes, you can be up and running working through the Gremlin tutorials. Gremlin will provide you with a REPL that will let you experiment with small graphs and get immediate feedback. Even if you don't use Gremlin in your production system, the knowledge gained at the REPL will help you validate your designs and can serve as a precursor to more rigorous unit testing and development.

If you prefer working directly with Neo4j's API's, their traversal framework tutorial should help.

Is it true that if my backend is entirely Neo4j-based, that I would have no need for Hibernate (which is my usual ORM)?

Since you're new to Neo4j, I would recommend that you avoid ORM's until you first understand what the ORM needs to do for you. See how much pain you're really going to experience mapping the results of your query to your domain. If the pain can be ameliorated by an ORM, the Spring-Data framework mentioned by Peter may be useful.

In all likelihood, you will probably be just fine. I have worked on several projects where the accidental complexity introduced by the ORM far outweighed the benefits. Mapping the query results to the domain was in no way the most complicated part of the system.

like image 94
Bobby Norton Avatar answered Sep 18 '22 08:09

Bobby Norton


Instead of Hibernate, I would take a look at http://www.springsource.org/spring-data/neo4j which is annotation driven, supported by Spring and works very well. Would this be something to work with?

like image 28
Peter Neubauer Avatar answered Sep 17 '22 08:09

Peter Neubauer