Re: [Neo4j] Persistence of POJOs to Neo4j using JDO/JPA

430 views
Skip to first unread message

Michael Hunger

unread,
Jul 29, 2012, 4:34:32 PM7/29/12
to ne...@googlegroups.com
Andy,

that's great news thanks a lot. What about starting by just blogging the content of this email? We could then re-blog/promote it. 
Or if you don't have the time we can also blog it on blog.neo4j.org

Thanks a lot for all your work, seems that quite an effort went into the plugin.

Do you have a sample application that you could imagine for showing off the power and ease of the approach? 

We can definitely put a link to it onto the resources section of neo4j.org

Cheers

Michael

Am 29.07.2012 um 20:43 schrieb datanucleus:

Hi,
FYI, DataNucleus JDO/JPA now has a prototype plugin for persisting normal Java objects to Neo4J; it already supported persistence to RDBMS, ODBMS, XML, JSON, Excel, ODF, MongoDB, HBase, AppEngine, VMForce, Cassandra, LDAP and others so supporting some of the nice graph databases like Neo4J makes a lot of sense. 

To use this support you mark your model classes with JDO or JPA metadata (annotations or XML) in the normal way you would for RDBMS (or any other datastore), and write your JDO or JPA persistence code in the normal way. The only difference is that the data is persisted into Neo4j transparently. I've not had time to write up a tutorial yet, but the model and persistence code would be identical to persisting to any other datastore, just that in the definition of the datastore "URL" it would be something like
datanucleus.ConnectionURL=neo4j:{my_datastore_location}

This plugin is not yet released, as such, but is available as a nightly build for anyone wishing to give it a try.

What it currently supports :
  • Each object of a class becomes a Node.
  • Supports datastore identity, application identity, and nondurable identity
  • Supports versioned objects
  • Fields of all primitive and primitive wrappers can be persisted
  • Fields of many other standard Java types can be persisted (Date, URL, URI, Locale, Currency, JodaTime, javax.time, plus many more).
  • 1-1, 1-N, M-N, N-1 relations are persisted as Relationships (doesn't support Maps currently)
  • JDOQL/JPQL queries can be performed, and the operators &&, ||, ==, !=, >, >=, <, <= are processed using Cypher, with any remaining syntax handled in-memory currently.
What is likely to be added (hopefully soon)
  • Processing of more JDOQL/JPQL syntaxis in Cypher to minimise any in-memory processing
  • Embedded fields (and querying of embedded fields)
  • Check for duplicate object identity
  • Support for using the (Neo4j-assigned) node "id" as a global unique object id

Would it be possible to get a link to it put on the Neo4j website or docs in a convenient place?

datanucleus

unread,
Jul 30, 2012, 2:08:12 AM7/30/12
to ne...@googlegroups.com
Thanks Michael. I added a post on the DataNucleus blog, 
http://datanucleus.blogspot.co.uk/2012/07/persistence-to-neo4j-graph-datastores.html

Since we already had quite a few datastore plugins (allowing copy across of some features), this one actually took 2-3 days to get to its current point. 

As for a sample application I'm intending on making it run on our standard JDO and JPA tutorial samples (as shown for MongoDB here for JDO http://www.datanucleus.org/products/accessplatform/jdo/guides/tutorial_mongodb.html and for JPA http://www.datanucleus.org/products/accessplatform/jpa/guides/tutorial_mongodb.html ), but I just need to add support for a (numeric) value generator with Neo4j (since those tutorials use one). In the meantime, any JPA or JDO simple application ought to be fine. I'll post back when it provides all features for those tutorials.

Peter Neubauer

unread,
Jul 30, 2012, 4:37:33 PM7/30/12
to ne...@googlegroups.com
Very cool Andy,
thank you for that cool piece of contribution! How production ready do
you think this is - would you recommend it to users yet?

Cheers,

/peter neubauer

G: neubauer.peter
S: peter.neubauer
P: +46 704 106975
L: http://www.linkedin.com/in/neubauer
T: @peterneubauer

Wanna learn something new? Come to @graphconnect.

datanucleus

unread,
Jul 31, 2012, 4:21:58 AM7/31/12
to ne...@googlegroups.com
Thx Peter,

I've just released v3.1.0-m1 (1st milestone for use with DataNucleus v3.1) of the "datanucleus-neo4j" plugin. It includes all features I mentioned before, plus support for embedded and nested embedded fields and the querying of those fields, support for use of Neo4j node id as a global object identity, a check for duplicated identity on persist, support for JDOQL/JPQL ordering in Cypher, and a few other things. 

It ought to be in the Maven central repo tomorrow (1st Aug), and in the meantime can be found in the DataNucleus Maven repo at
under group "org.datanucleus"

The tutorials I promised are also now online at
so please report any typos/errors.

As for whether it is "production ready", well everyone has their own definition of that :-) but it passes all of my tests for the above functionality so I'd definitely recommend people to try persistence using it, and view Nodes/Relationships in the datastore to gain some confidence/understanding of what it is doing. Obviously the DataNucleus persistence engine + JDO/JPA API implementations are tested over many years so not likely a problem from that side. If some query syntax is not yet implemented to use Cypher it will currently evaluate the query in-memory (hence not efficient) - see the log when running the query. Raise any issues at http://www.datanucleus.org/servlet/jira/browse/NUCNEOFORJ

Reply all
Reply to author
Forward
0 new messages