Database Reference
In-Depth Information
Neo4jTemplate: Power to the people!
The Neo4jTemplate class also provides many other low-level utility methods for oper-
ating on, querying, and gaining access to nodes and relationships. This is one of the ways
inwhichSDNprovidesahookforyoutodropdowntothecorelow-levelAPIifyoureally
need to get into the “belly of the beast” and have more fine-grained control. Be sure to ex-
plore all of the other methods available to you at some point.
The following listing is an example that illustrates how to save and load the User entity
using the Neo4jTemplate class in its most basic form.
Listing 9.7. A basic Neo4jTemplate example
First up, the Neo4jTemplate class needs a reference to the underlying graph database
it's ultimately operating on to perform its tasks. This is the same GraphDatabaseSer-
vice you've used in previous chapters to work with the native Neo4j constructs.
Although you appear to be holding true to the aspiration of only having to deal with real
domain objects, there's still a lot of “noise” (all that boilerplate transaction code) in listing
9.7 . You could do better in this regard by making full use of the Spring framework with its
dependencyinjection(DI)functionalityandallthatcomeswithit.Movinginthisdirection,
your code can be transformed to what you see in the following listing.
 
Search WWH ::




Custom Search