Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Fresh Release — Neo4j OGM 2.0 Milestone 1

DZone's Guide to

Fresh Release — Neo4j OGM 2.0 Milestone 1

We’re very excited about the new Neo4j OGM (Object Graph Mapper) 2.0 release, published this week. It introduces some exciting new features, performance improvements, and bug fixes that many of you have been asking for.

· Database Zone
Free Resource

Learn how to create flexible schemas in a relational database using SQL for JSON.

We’re very excited about the new Neo4j OGM (Object Graph Mapper) 2.0 release, published this week.

This new release introduces some exciting new features, performance improvements, and bug fixes that many of you have been asking for. So, without further ado, let’s take a look at what’s new in Neo4j OGM 2.0.

The regular disclaimer about milestone releases still applies: Releases like this one are for development and experimentation only as not all features are in their finalized form. Click here for the fully stable version of the Neo4j OGM.

Drivers

The big news is that we have revamped the connection mechanism between Neo4j and your application by introducing the concept of drivers. As a result, we now support connecting to embedded instances as well as remote instances of Neo4j. 

The OGM Driver interface provides an abstraction over these different kinds of connections, so you can swap one driver implementation for another without needing to change any of your code. This makes testing much easier: you can configure your tests to use an Embedded Driver, while using the HTTP Driver.

The Embedded Driver also allows you to run your application as an Unmanaged Extension in a Neo4j server, without the overhead of having to create an in-process HTTP server.

Even better, the new drivers mechanism is already fully enabled for the Bolt protocol, which will be released with Neo4j 3.0, and we expect to be able to support it as soon 3.0 goes to GA.

Performance Improvements

The other piece of big news here is that the Cypher statement generator for the OGM has been completely refactored to provide support for multi-statement queries. This means that we can now batch up parts of the request to take advantage of powerful features in Cypher, such as UNWIND.

When persisting object graphs with a large number of related entities, our standard queries now perform orders of magnitude faster than before, and crucially don’t compromise memory on the server.

In addition, a new Cypher statement generator strategy has also been introduced, so that in future releases, we’ll be able to use different implementations to best take advantage of the capabilities of different versions of Neo4j.

Mapping Custom Query Results to Domain Entities

There have been many requests to support the mapping of nodes and relationship entities returned by custom Cypher queries to domain objects. We are happy to announce that this has been included in 2.0.

A query such as: 

MATCH (user:User {name: {username})-[rating:RATED]->(movie:Movie) RETURN u,r,m 

executed by Session.query() will continue to return a Result which contains keys for userrating, and movie but the values are now domain node and relationship entities linked by relationships returned in the query. 

This will make it much easier to deal with the results of custom queries and improve performance since your code will no longer need an additional load of the entity by ID.

Bug Fixes

There have been a number of bug fixes in 2.0. The most significant of these are as follows:

    • Retrying http requests in the event of NoHttpResponseException
    • Fixing http-client connection leaks when a request returns a 300/400/500 response code

Documentation

Naturally, the introduction of drivers means a few API changes, but we have tried to keep these to a minimum.

You can find the reference manual for Neo4j OGM 2.0-M01 here.

The sample application–OGM University–has also been updated to use OGM 2.0-M01 with embedded Neo4j and with a remote instance.

Feedback

We’d love your feedback on the new features and improvements in OGM 2.0. Let us know what you think–what you like, what you don’t, and where you think we can improve things. 

You can let us know on Stack Overflow, on GitHub, or on our public Slack channel.

Happy Graph mapping!


Andreas & the Neo4j OGM team 

Create flexible schemas using dynamic columns for semi-structured data. Learn how.

Topics:
neo4j ,release ,nosql ,databases ,graph databases

Published at DZone with permission of Andreas Kollegger, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

THE DZONE NEWSLETTER

Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

X

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}