diff --git a/src/docbkx/index.xml b/src/docbkx/index.xml index 2b664ac48..87cb48bbc 100644 --- a/src/docbkx/index.xml +++ b/src/docbkx/index.xml @@ -4,10 +4,16 @@ Good Relationships - The Spring Data Graph Guidebook + The Spring Data Graph Guide Book &version; + + + + + + Michael @@ -27,11 +33,6 @@ - - - - - Copies of this document may be made for your own use and for distribution diff --git a/src/docbkx/introduction/about.xml b/src/docbkx/introduction/about.xml index 7af3c9684..916fa350a 100644 --- a/src/docbkx/introduction/about.xml +++ b/src/docbkx/introduction/about.xml @@ -2,38 +2,46 @@ - About this Guide Book + About this guide book - - - - - + Welcome to the Spring Data Graph Guide Book. Thank you for taking the time to get an in depth look + into Spring Data Graph. + This project is part of the Spring Data project, + which brings the convenient programming model of the Spring Framework to modern NOSQL databases. + Spring Data Graph, as the name alludes to, aims to provide support for graph databases. It currently + supports Neo4j. - Welcome to the Spring Data Graph Guide Book. Thank you for taking the time to get an in depth look into Spring Data Graph Library. Spring Data Graph is part of the Spring Data project which - brings the convenient programming model of the Spring Framework to modern (mainly NOSQL) datastores. - Spring Data Graph currently provides integration for the Neo4j Graph Database. - - It was written by developers for developers. So hopefully we've created a documentation that is well received by - our peers. - - If you have any feedback to the Spring Data Graph Library or this book, please provide it via SpringSource JIRA, - the SpringSource NOSQL Forum, github comments or issues or the Neo4j mailing list. - - This book is presented as a duplex book, a term coined by Martin Fowler. A duplex book consists of at least two - parts. The first part is an easily accessible narrative, that gives the reader an overview of the topics contained - in the book. It contains lots of examples and more general discussion topics. This should be the only part of - the book that is required to be read cover-to-cover. - - We chose a tutorial describing the creation of a web applicaton (cineasts.net) that allows movie enthusiasts to - find the favorites, rate them, connect with each other and enjoy social features. The application is running on - Neo4j using Spring Data Graph and the well known Spring Web Stack. - - The second part is the classic reference documentation containing the detailed information about the library. - It discusses the programming model, the underlying assumptions, used toolset (like aspectj) as well as the APIs - for the object-graph mapping and the template approach. The reference docs should be mainly used to look up - concrete bits of information or to dig deeper into certain topics. + It was written by developers for developers. Hopefully we've created a document that is well received + by our peers. - + + If you have any feedback on Spring Data Graph or this book, please provide it via the + SpringSource JIRA, the + SpringSource NOSQL Forum, + github comments or issues, + or the Neo4j mailing list. + + + This book is presented as a duplex book, + a term coined by Martin Fowler. A duplex book consists of at least two parts. The first part is an easily + accessible tutorial that gives the reader an overview of the topics contained in the book. It contains lots + of examples and discussion topics. This part of the book is highly suited for cover-to-cover reading. + + + We chose a tutorial describing the creation of a web application that allows movie enthusiasts to + find their favorite movies, rate them, connect with fellow movie geeks, and enjoy social features such as + recommendations. The application is running on Neo4j using Spring Data Graph and the well-known Spring + Web Stack. + + + The second part of the book is the classic reference documentation, containing detailed information about + the library. It discusses the programming model, the underlying assumptions, and internals, as well as the + APIs for the object-graph mapping. The reference documentation is typically used to look up concrete bits of + information, or to drill down into certain topics. For hackers wanting to really delve into Spring Data + Graph, it can of course also be read cover-to-cover. + + + Enjoy the book! + + diff --git a/src/docbkx/introduction/emil.xml b/src/docbkx/introduction/emil.xml index 496f47c03..08de66038 100644 --- a/src/docbkx/introduction/emil.xml +++ b/src/docbkx/introduction/emil.xml @@ -1,11 +1,10 @@ - - - Foreword by Emil Eifrem - - Emil Eifrem, CEO of Neo Technology - - + +Foreword by Emil Eifrem + + Emil Eifrem, CEO of Neo Technology + + diff --git a/src/docbkx/introduction/get-started.xml b/src/docbkx/introduction/get-started.xml deleted file mode 100644 index 47f259c05..000000000 --- a/src/docbkx/introduction/get-started.xml +++ /dev/null @@ -1,93 +0,0 @@ - - - - Getting Started - - NOSQL databases have only recently come to prominence, even though some of them have existed for a few years now. - That's why this document will not only guide you through the relevant parts of the Spring Data Graph - API, but also explain some key concepts of graph databases. - - - After reading this document, you should be able to integrate Spring Data Graph into your applications. - If there are any inaccuracies, issues or if you just think the explanations are too complicated, please feed that back to us. Your input will also benefit future readers of this documentation. For details on how to get help - and provide feedback, see . - - -
- First Steps - - As explained in , Spring Data Graph provides integration - between the Spring framework and graph databases. As we said in the introduction , familiarity with the Spring framework is assumed to get the most out of this book. - But we will explain graph databases and Neo4j in particular in a little more detail. - The main focus of this document is to explain the steps needed to get an interesting Spring Data Graph application up and running. - - -
- Knowing Spring - Spring Data Graph makes heavy use of Spring Framework's core functionality, - such as the IoC container, - converter API and the - AOP infrastructure. While it is less important - to know the Spring APIs, understanding the concepts behind them is essential. - The Spring Framework documentation - home page is a good starting point for - developers who want to become more familiar with the Spring Framework. -
-
- Knowing NOSQL and graph databases - The recent interest in NOSQL databases has been driven by the need to find the better storage solutions for different kinds of data and access patterns. The NOSQL mantra is that databases should fit the data, not the other way round. - The NOSQL space is overflowing with interesting and useful technology. But as a consequence, each store tends to implement its own data access API, leading to a steep learning curve for developers intent on using polyglot persistence. Spring Data aims to ease this burden by - providing consistent abstractions over those underlying data access APIs. - - - Graph databases are a particularly good fit for large networks of connected information (objects). They map objects to nodes and connections to - relationships. Examples of such datasets are social networks, geospatial information, network layouts, and hardware or dependency graphs. - Neo4j is the first graph database that is tightly integrated with the Spring Data Graph project. - -
-
- Trying Out The Samples - Spring Data Graph comes with a number of samples - and unit test cases (if you accessed the sources via - github or Maven). - - For more information on the samples, see . -
-
- -
- Need Help? - - If you encounter issues or you are just looking for advice, feel free to use one of the links below: - -
- Spring Data homepage - The Spring Data homepage provides all the necessary links for information, community forums and code repositories. - -
-
- Professional Support - Professional, from-the-source support, with guaranteed response time, is available from SpringSource, - the company behind Spring Data and the Spring Framework. - -
-
- -
- Follow the Development - - For information on the Spring Data source code repository, nightly builds and snapshot artifacts please see the Spring Data home - page. - - You can help make Spring Data better serve the needs of the Spring community by interacting with developers through the - community forums. - If you find a bug or want to suggest an improvement, - please create a ticket on the Spring Data Graph issue tracker. - To stay up to date with the latest news and announcements in the Spring eco system, subscribe to the - Spring Community Portal. - Lastly, you can follow the SpringSource Data blog or the project team on Twitter - (@SpringData) -
- -
diff --git a/src/docbkx/introduction/introduction.xml b/src/docbkx/introduction/introduction.xml deleted file mode 100644 index 6d4495a35..000000000 --- a/src/docbkx/introduction/introduction.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - This document is the reference guide for Spring Data Graph. - It explains the underlying concepts, usage, infrastructure of the framework and the behaviour of the underlying graph database. - - - For an introduction to graph databases, Spring, or Spring Data examples, please refer to - . This documentation refers only to Spring Data Graph and - assumes that the reader is familiar with Spring concepts. - diff --git a/src/docbkx/introduction/requirements.xml b/src/docbkx/introduction/requirements.xml deleted file mode 100644 index cb016d702..000000000 --- a/src/docbkx/introduction/requirements.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - Requirements - - Spring Data Graph 1.x requires JDK level 6.0 or higher, - and Spring Framework - 3.0.x or higher. - - For the graph database, Neo4j 1.2 or higher is required. - Neo4j has a dependency on Apache Lucene for indexing. Users are encouraged to use the latest version of Neo4j - available. - - - For building the project, Apache Maven (version 2.10 and above) is recommended. - - diff --git a/src/docbkx/introduction/rod.xml b/src/docbkx/introduction/rod.xml index e65036977..ba0af1b08 100644 --- a/src/docbkx/introduction/rod.xml +++ b/src/docbkx/introduction/rod.xml @@ -1,43 +1,47 @@ - + Foreword by Rod Johnson - - I’m excited about Spring Data Graph for several reasons. - - + + I’m excited about Spring Data Graph for several reasons. + + First, this project is in a very important space. We are in an era of transition. A very few years ago, a relational database was a given for storing nearly all the data in nearly all applications. While relational databases remain important, new application requirements and massive data proliferation have prompted a richer - choice of data stores. Graph databases have some very interesting strengths, and Neo4J is proving itself - valuable in many applications. It’s a choice you should add to your toolbox. - + choice of data stores. Graph databases have some very interesting strengths, and Neo4j is proving itself + valuable in many applications. It's a choice you should add to your toolbox. + + Second, Spring Data Graph is an innovative project, which makes it easy to work with one of the most interesting new data stores. Unfortunately, the proliferation of new data stores has not been matched by innovation in programming models to work with them. Ironically, just after modern ORM mapping made working with relational data in Java relatively easy, the data store disruption occurred, and developers were back to square one: struggling once more with clumsy, low level APIs. Working with most non-relational technologies is overly - complex and imposes too much work on developers. Spring Data Graph makes working with Neo4J amazingly easy, and + complex and imposes too much work on developers. Spring Data Graph makes working with Neo4j amazingly easy, and therefore has the potential to make you more successful as a developer. Its use of AspectJ to eliminate persistence code from your domain model is truly innovative, and on the cutting edge of today’s Java technologies. - - Third, I’m excited about Spring Data Graph for personal reasons. I no longer get to write code as often as I - would like. My initial convictions that Spring and AspectJ could both make building applications with Neo4J + + + Third, I'm excited about Spring Data Graph for personal reasons. I no longer get to write code as often as I + would like. My initial convictions that Spring and AspectJ could both make building applications with Neo4j dramatically easier and cross-store object navigation possible gave me an excuse for a much-needed coding binge - early in 2011. This led to a prototype of what became Spring Data Graph — at times written paired with Emil. I’m - sure the vast majority of my code has long since been replaced (probably for the better) by coders who aren’t + early in 2010. This led to a prototype of what became Spring Data Graph — at times written paired with Emil. I’m + sure the vast majority of my code has long since been replaced (probably for the better) by coders who aren't rusty — thanks Michael and Thomas! — but I retain my pleasant memories. - + + Finally, Spring Data Graph is part of the broader Spring Data project: one of the key areas in which Spring is innovating to help meet new application requirements. I encourage you to explore Spring Data, and — better still — become involved in the community and contribute. - + + Enjoy the Spring Data Graph book, and happy coding! - + Rod Johnson, Founder, Spring and SVP, Application Platform, VMware - + diff --git a/src/docbkx/introduction/why-sd-graph.xml b/src/docbkx/introduction/why-sd-graph.xml deleted file mode 100644 index 1a932be31..000000000 --- a/src/docbkx/introduction/why-sd-graph.xml +++ /dev/null @@ -1,39 +0,0 @@ - - - - Why Spring Data Graph? - - NOSQL - stores provide novel storage solutions to suit the - data storage requirements of modern applications. - - - Graph databases provide excellent support for connected data - that is data that easily can - be structured as connected nodes in a network. - Property graph databases like Neo4j support an arbitrary number of named properties on - nodes and relationships. Neo4j is highly performant when traversing large, highly-connected datasets with - millions of nodes and relationships, even on commodity hardware. - - - Neo4j is an open source graph database written in Java. It has excellent performance characteristics while providing ACID - semantics and full transactional support (both JTA and XA transactions). Neo4j can run as a lightweight embedded database as well as a standalone - server that exposes the API via a rich REST interface. - - - The Spring Data Graph framework makes it easy to - integrate graph databases in existing or new Spring applications. It provides - infrastructure that reduces boilerplate data access code and uses - common patterns and idioms that are well-known in the Spring community, such as declarative transaction management. - Those practices are based on a simple POJO programming model that leverages - annotations to add metadata. It can be integrated in any part of a Spring application, - including the Web or service layers. - - - A special use case of Spring Data Graph is the cross-store functionality that can extend - existing JPA data models with new, graph database backed parts (properties, entities, relationships). - These parts are stored exclusively in the graph database while being transparently - integrated with the JPA entities. This enables easy and seamless addition of new features - that have not been available to JPA-based applications previously. - - diff --git a/src/docbkx/reference/aspectj-details.xml b/src/docbkx/reference/aspectj-details.xml index 8fcb0b1d2..a88e35d1c 100644 --- a/src/docbkx/reference/aspectj-details.xml +++ b/src/docbkx/reference/aspectj-details.xml @@ -3,56 +3,55 @@ AspectJ details - The object graph mapper of Spring Data Graph relies heavily on AspectJ. AspectJ is the Java implementation of - the Aspect - Oriented Programming paradigm that allows easy extraction and controlled application of so called - cross cutting concerns. Cross cutting concerns are repetitive tasks in a system (e.g. logging, security, - auditing, caching, transaction scoping) that are difficult to extract using the normal OO paradigms. The means - of the OO paradigm, of subclassing, polymorphism, overriding and delegation are still very cumbersome to use - with many of those concerns applied in the codebase. Also the flexibility is limited or would add quite a number - of configuration options or parameters. + The object graph mapper of Spring Data Graph relies heavily on AspectJ. AspectJ is a Java implementation + of the aspect-oriented + programming paradigm that allows easy extraction and controlled application of so-called + cross-cutting concerns. Cross-cutting concerns are typically repetitive tasks in a system (e.g. logging, + security, auditing, caching, transaction scoping) that are difficult to extract using the normal OO + paradigms. Many OO concepts, such as subclassing, polymorphism, overriding and delegation are still + cumbersome to use with many of those concerns applied in the code base. Also, the flexibility becomes + limited, potentially adding quite a number of configuration options or parameters. - The learning curve for the AspectJ pointcut language is quite slow but the developer who uses Spring Data Graph - will not be confronted with that. Users do not have care about to hooking into a framework mechanism or having - to extend a framework superclass. + The AspectJ pointcut language can be intimidating, but a developer using Spring Data Graph will not have + to deal with that. Users don't have care about to hooking into a framework mechanism, or having to extend + a framework superclass. - That's why AspectJ uses a declarative approach, defining concrete advice, which is just - the piece of code that contains the implementation of the concern. AspectJ advice can for instance - be applied before, after, or instead of a method or constructor call, or variable access. This is declared - using AspectJ's expressive pointcut language that is able to express any place within a code structure - or flow. - AspectJ is also able to introduce new methods, fields, annotations, interfaces, and superclasses - to existing classes. + AspectJ uses a declarative approach, defining concrete advice, which is just pieces of code that contain + the implementation of the concern. AspectJ advice can for instance be applied before, after, or instead + of a method or constructor call. It can also be applied on variable and field access. This is declared + using AspectJ's expressive pointcut language, able to express any place within a code structure or flow. + AspectJ is also able to introduce new methods, fields, annotations, interfaces, and superclasses to + existing classes. - Spring Data Graph uses both mechanisms internally. First, when encountering @NodeEntity or - @RelationshipEntity annotations it introduces a new interface NodeBacked or - RelationshipBacked, depending on the annotation type. Secondly, it introduces fields and methods - to the annotated class. See for more - information on the methods introduced. + Spring Data Graph uses a mix of these mechanisms internally. First, when encountering the + @NodeEntity or @RelationshipEntity annotations it introduces a new interface + NodeBacked or RelationshipBacked to the annotated class. Secondly, it introduces + fields and methods to the annotated class. See + for more information on the methods introduced. Spring Data Graph also leverages AspectJ to intercept access to fields, delegating the calls to the graph database instead. Under the hood, properties and relationships will be created. - So how is an aspect applied to a concrete class? This can be either done at compile time with the - AspectJ Java compiler (ajc) that takes source files and aspect definitions, and then compiles the source files - while adding all the necessary interception code for the aspects to hook in where they're declared to. This is - known as compile-time weaving. At runtime only a small AspectJ runtime is needed, as the bytecode of the - classes has already been rewritten to delegate appropriate calls via the declared advice in the aspects. + So how is an aspect applied to a concrete class? At compile time , the AspectJ Java compiler (ajc) takes + source files and aspect definitions, and compiles the source files while adding all the necessary + interception code for the aspects to hook in where they're declared to. This is known as compile-time + weaving. At runtime only a small AspectJ runtime is needed, as the byte code of the + classes has already been rewritten to delegate the appropriate calls via the declared advice in the aspects. - A caveat of using compile-time weaving is that all source files that should be part of the weaving process must - be compiled with the AspectJ compiler. Fortunately, this is all taken care of seamlessly by the AspectJ Maven - plugin. + A caveat of using compile-time weaving is that all source files that should be part of the weaving + process must be compiled with the AspectJ compiler. Fortunately, this is all taken care of seamlessly + by the AspectJ Maven plugin. - AspectJ also supports other types of weaving, for example load-time weaving and runtime weaving. These are + AspectJ also supports other types of weaving, e.g. load-time weaving and runtime weaving. These are currently not supported by Spring Data Graph. diff --git a/src/docbkx/reference/cross-store.xml b/src/docbkx/reference/cross-store.xml index fa7a37fa1..f391d04f2 100644 --- a/src/docbkx/reference/cross-store.xml +++ b/src/docbkx/reference/cross-store.xml @@ -1,142 +1,159 @@ - Cross-store persistence - The Spring Data Graph project support cross-store persistence which allows parts of the data mode to be stored in a traditional - JPA datastore (RDBMS) and other parts of the data model (even partial entites, that is some properties or relationships) in a graph - store. - - - This allows existing JPA-based applications to embrace NOSQL data stores to evolve certain parts of their model. - Possible use cases are adding social network or geospatial information to existing applications. - -
- Partial graph persistence + Cross-store persistence + + The Spring Data Graph project support cross-store persistence, which allows for parts of the data to be + stored in a traditional JPA data store (RDBMS), and other parts in a graph store. This means that an entity + can be partially stored in e.g. MySQL, and partially stored in Neo4j. + + + This allows existing JPA-based applications to embrace NOSQL data stores for evolving certain parts + of their data model. Possible use cases include adding social networking or geospatial information to + existing applications. + +
+ Partial entities - Partial graph persistence is achieved by restricting the Spring Data Graph aspects to explicitly annotated parts of - the entity. Those fields will be made transient by the aspect so that JPA ignores them and won't try to persist those - attributes. + Partial graph persistence is achieved by restricting the Spring Data Graph aspects to manage only + explicitly annotated parts of the entity. Those fields will be made @Transient by the + aspect so that JPA ignores them. - A backing node in the graph store is only created when the entity has been assigned a JPA id. Only then will the connection between the - two stores be kept. Until the entity has been persisted, its state is just kept inside the POJO (detached state) and flushed to the - backing graph store afterwards. - - - The connection between the two entities is kept via a FOREIGN_ID field in the node that contains the JPA id - (currently only single value ids are supported). The entity class can be resolved via the - TypeRepresentationStrategy that manages the Java type hierarchy within the graph. With the id and class, - you can then retrieve the appropriate JPA entity for a given node. + A backing node in the graph store is only created when the entity has been assigned a JPA ID. Only + then will the association between the two stores be established. Until the entity has been persisted, + its state is just kept inside the POJO (in detached state), and then flushed to the backing graph + database on persist(). - - The other direction is handled by indexing the Node with the FOREIGN_ID index which contains a concatenation of the fully qualified class - name of the JPA entity and the id. So it is possible on instantiation of a JPA id via the entity manager (or some other means like creating - the POJO and setting its id manually) to find the matching node using the index facilities and reconnect them. - - - Using those mechanisms and the Spring Data Graph aspects a single POJO can contain fields that are handled by JPA and other fields - (which might be relationships as well) that are handled by Spring Data Graph. - -
- @NodeEntity(partial = "true") - - When annotating an entity with partial true, Spring Data Graph assumes that this is a cross-store entity. So its only responsibility is for the fields - annotated with Spring Data Graph annotations. JPA should not take care of these fields (they should be annotated with @Transient). In this mode of - operation Spring Data Graph also handles the cross-store connection via the content of the JPA id field. - -
-
- @GraphProperty - - For common fields containing primitive or convertible values that wouldn't have to be annotated in exclusive Spring Data Graph operations this - explicit declaration is necessary to be sure that they are intended to be stored in the graph. These fields should then be made transient - so that JPA doesn't try to take care of them as well. - -
- - The following example is taken from the Spring Data Graph examples, - it is contained in the myrestaurant-social project. - - + The association between the two entities is maintained via a FOREIGN_ID field in the node, that + contains the JPA ID. Currently only single-value IDs are supported. The entity class can be resolved + via the TypeRepresentationStrategy that manages the Java type hierarchy within the graph + database. Given the ID and class, you can then retrieve the appropriate JPA entity for a given node. + + + The other direction is handled by indexing the Node with the FOREIGN_ID index which contains a + concatenation of the fully qualified class name of the JPA entity and the ID. The matching node + can then be found using the indexing facilities, and the two entities can be reassociated. + + + Using these mechanisms and the Spring Data Graph aspects, a single POJO can contain some fields + handled by JPA and others handles by Spring Data Graph. This also includes relationship fields persisted + in the graph database. + +
+
+ Cross-store annotations + + Cross-store persistence only requires the use of one additional annotation: @GraphProperty. + See below for details and an example. + +
+ @NodeEntity(partial = "true") + + When annotating an entity with partial = true, this marks it as a cross-store entity. + Spring Data Graph will thus only manage fields explicitly annotated with @GraphProperty. + +
+
+ @GraphProperty + + Fields of primitive or convertible types do not normally have to be annotated in order to be + persisted by Spring Data Graph. In cross-store mode, Spring Data Graph only + persists fields explicitly annotated with @GraphProperty. JPA will ignore these fields. + +
+ + The following example is taken from the + Spring Data Graph examples + myrestaurants-social project: + + + Cross-store node entity + friends; + @RelatedTo(type = "friends", elementClass = UserAccount.class) + Set friends; - @RelatedToVia(type = "recommends", elementClass = Recommendation.class) - Iterable recommendations; + @RelatedToVia(type = "recommends", elementClass = Recommendation.class) + Iterable recommendations; - @Temporal(TemporalType.TIMESTAMP) - @DateTimeFormat(style = "S-") - private Date birthDate; + @Temporal(TemporalType.TIMESTAMP) + @DateTimeFormat(style = "S-") + private Date birthDate; - @ManyToMany(cascade = CascadeType.ALL) - private Set favorites; + @ManyToMany(cascade = CascadeType.ALL) + private Set favorites; - @Id - @GeneratedValue(strategy = GenerationType.AUTO) - @Column(name = "id") - private Long id; + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name = "id") + private Long id; - @Transactional - public void knows(UserAccount friend) { - relateTo(friend, "friends"); - } + @Transactional + public void knows(UserAccount friend) { + relateTo(friend, "friends"); + } - @Transactional - public Recommendation rate(Restaurant restaurant, int stars, String comment) { - Recommendation recommendation = relateTo(restaurant, Recommendation.class, "recommends"); - recommendation.rate(stars, comment); - return recommendation; - } - public Iterable getRecommendations() { - return recommendations; - } - } + @Transactional + public Recommendation rate(Restaurant restaurant, int stars, String comment) { + Recommendation recommendation = relateTo(restaurant, Recommendation.class, "recommends"); + recommendation.rate(stars, comment); + return recommendation; + } + public Iterable getRecommendations() { + return recommendations; + } +} ]]> -
-
- Configuring cross-store persistence - - Configuring cross-store persistence is done similarly to the default Spring Data Graph operations. As soon as you refer - to an entityManagerFactory in the xml-namespace it is set up for cross-store persistence. - - +
+
+ Configuring cross-store persistence + + Configuring cross-store persistence is done similarly to the default Spring Data Graph configuration. + All you need to do is to specify an entityManagerFactory in the XML namespace + config element, and Spring Data Graph will configure itself for cross-store use. + + + Cross-store Spring configuration + + xsi:schemaLocation=" + http://www.springframework.org/schema/beans + http://www.springframework.org/schema/beans/spring-beans-3.0.xsd + http://www.springframework.org/schema/context + http://www.springframework.org/schema/context/spring-context-3.0.xsd + http://www.springframework.org/schema/data/graph + http://www.springframework.org/schema/data/graph/datagraph-1.0.xsd + "> - + + id="entityManagerFactory"> ]]> + -
+ +
diff --git a/src/docbkx/reference/neo4j-server.xml b/src/docbkx/reference/neo4j-server.xml index a447a7290..d51d96b61 100644 --- a/src/docbkx/reference/neo4j-server.xml +++ b/src/docbkx/reference/neo4j-server.xml @@ -3,80 +3,87 @@ Neo4j Server - Neo4j is not only available in embedded mode, it can also be installed and run as a server that is accessed - via a REST API. Spring Data Graph provides two-fold integration for infrastructure. + Neo4j is not only available in embedded mode. It can also be installed and run as a stand-alone server + accessible via a REST API. Developers can integrate Spring Data Graph into the Neo4j server infrastructure + in two ways: in an unmanaged server extension, or via the REST API.
Server Extension - What is the use-case for writing server extensions? The REST API is a pretty generic representation of the - Neo4j core API. It is nice for getting started and simple scenarios. For more involved solutions that require - high speed and high volume access to the embedded graph database, writing a server extension that is able to - process external parameters and return just the relevant information to the calling client is preferrable. + When should you write a server extension? The default REST API is essentially a REST'ified representation + of the Neo4j core API. It is nice for getting started, and for simpler scenarios. For more involved + solutions that require high-volume access or more complex operations, writing a server extension that + is able to process external parameters, do all the computations locally in the plugin, and then return + just the relevant information to the calling client is preferable. - The Neo4j server has two built in extension mechanisms. - It is possible to add extensions to existing endpoints - like the graph database, nodes or relationships - add new URIs or methods to those. This is achieved by - writing Server Plugins. + The Neo4j Server has two built-in extension mechanisms. It is possible to extend existing URI endpoints + like the graph database, nodes, or relationships, adding new URIs or methods to those. This is achieved + by writing a server plugin. + This plugin type has some restrictions though. - For complete freedom in your implementation an unmanaged extension - might be the right solution. Unmanaged - extensions are Jersey resource implementations. - The resources constructors or methods can get the GraphDatabaseService injected to execute the - necessary operations and return appropriate Representations. + For complete freedom in the implementation, an + unmanaged extension + can be used. Unmanaged extensions are essentially Jersey + resource implementations. The resource constructors or methods can get the + GraphDatabaseService injected to execute the necessary operations and return appropriate + Representations. - Both kinds of extensions have to be packaged as a jar and added to the Neo4j-Server's plugin directory. - Server Plugins are picked up at server startup when they provide the necessary - META-INF.services/org.neo4j.server.plugins.ServerPlugin file for Javas service loader mechanism. - Unmanaged extensions have to be registered with the Neo4j Server configuration. - + Both kinds of extensions have to be packaged as JAR files and added to the Neo4j Server's plugin + directory. Server Plugins are picked up by the server at startup if they provide the necessary + META-INF.services/org.neo4j.server.plugins.ServerPlugin file for Java's ServiceLoader + facility. Unmanaged extensions have to be registered with the Neo4j Server configuration. + + Configuring an unmanaged extension + + - Running Spring Data Graph on the server is easy. You need to tell the server where to find the Spring Context - file, and which beans from it to expose, using what type: - + Server plugin initialization + - Now, your resources can be annotated with the beans they need, like this: - - - The SpringPluginInitializer merges the graph database service - with the spring configuration and registers the named beans as jersey Injectables. - It is still necessary to list the initializer fully qualified class name in a - file named META-INF/services/org.neo4j.server.plugins.PluginLifecycle. Then the Neo4j Server can pick up - and run the initialization classes before the the extensions are loaded. + + + Now, your resources can be annotated with the beans they need, like this: + + Jersey resource + + + The SpringPluginInitializer merges the GraphDatabaseService with the Spring configuration + and registers the named beans as Jersey Injectables. It is still necessary to list the + initializer's fully qualified class name in a file named + META-INF/services/org.neo4j.server.plugins.PluginLifecycle. The Neo4j Server can then pick + up and run the initialization classes before the extensions are loaded.
- Using Spring Data Graph as a REST-Client + Using Spring Data Graph as a REST client - Spring Data Graph can use the Java Rest Bindings which come as a drop in replacement for the - GraphDatabaseService API. Just by configuring the graphDatabaseService to be a - RestGraphDatabaseService pointing to the correct URL, a Neo4j-REST server can be used. + Spring Data Graph can use a set of Java REST bindings which come as a drop in replacement for the + GraphDatabaseService API. By simply configuring the graphDatabaseService to be a + RestGraphDatabase pointing to a Neo4j Server instance. - The Neo4j REST API does not allow keeping transactions open, which means that SDG is not transactional - when running against REST. + The Neo4j Server REST API does not allow for transactions to span across requests, which means + that Spring Data Graph is not transactional when running with a RestGraphDatabase. @@ -91,19 +98,19 @@ public class HelloWorldInitializer extends SpringPluginInitializer { 1.0.0.RELEASE ]]> - - Now, you set up the normal SDG configuration, but point the database to an URL instead of a local file, like this: - - REST-Client configuration - application context - + + Now, you set up the normal Spring Data Graph configuration, but point the database to an URL instead + of a local directory, like so: + + REST client configuration - application context + ]]> - - Your project is now set up to work against a remote Neo4j Server. + + Your project is now set up to work against a remote Neo4j Server.
diff --git a/src/docbkx/reference/neo4j.xml b/src/docbkx/reference/neo4j.xml index 0f364d7fd..eec2043c9 100644 --- a/src/docbkx/reference/neo4j.xml +++ b/src/docbkx/reference/neo4j.xml @@ -81,8 +81,7 @@
Neo4j usage - Traversal usage - Index usage - nodeIndex = indexManager.forNodes("a-node-index"); Node node = ...; Transaction tx = graphDb.beginTx(); diff --git a/src/docbkx/reference/performance.xml b/src/docbkx/reference/performance.xml index 28e467699..48d53c65f 100644 --- a/src/docbkx/reference/performance.xml +++ b/src/docbkx/reference/performance.xml @@ -3,38 +3,36 @@ Performance considerations - Although adding another layer of abstraction is always the solution to look for in software development, - each of those layers adds overhead and performance penalties. This chapter discusses the performance - implications of using Spring Data Graph on top of the native Neo4j API. + Although adding layers of abstraction is a common pattern in software development, each of these layers + generally adds overhead and performance penalties. This chapter discusses the performance implications + of using Spring Data Graph instead of the Neo4j API directly.
- When to use SDG? + When is Spring Data Graph right - The focus of Spring Data Graph is to add a convenience layer on top of the native Neo4j API. This should - enable developers to get up and running with the graph database very quickly, having their domain objects - mapped to the graph. Building on this foundation one can later explore other, more efficient ways to - explore and process the graph - if the performance requirements demand it. - - - Like any other object mapping framework, the domain entities that are created, read or persisted represent - only a small fraction of the data stored in the database. This is the set needed for a certain use-case to - be displayed, edited or processed in a low throughput fashion. The main advantages of using an object mapper - in this case is the ease of use of real domain objects in your business logic and also with existing - frameworks and libraries that expect Java POJOs as input or create them as results. - - - Spring Data Graph was not designed with a major performance focus. It adds some overhead to pure graph operations. - Something to keep in mind is, that the access of properties and relationships is a read trough in the attached - case. So to avoid multiple read-throughs it is sensible to store the result in a local variable at the scope of - use (method, class or jsp for example). - - - Most of the overhead comes from the use of the Java Reflection API, which is leveraged to provide - information about Annotations, Fields and Constructors. - Some of the information is already cached by the JVM and the library, so that only the first access gets a - performance penalty. + The focus of Spring Data Graph is to add a convenience layer on top of the Neo4j API. This enables + developers to get up and running with a graph database very quickly, having their domain objects + mapped to the graph with very little work. Building on this foundation, one can later explore other, + more efficient ways to explore and process the graph - if the performance requirements demand it. + + + + + + + + + + + Spring Data Graph was however not designed with a major focus on performance. It does add some overhead + to pure graph operations. Something to keep in mind is that any access of properties and relationships + will in general read through down to the database. To avoid multiple reads, it is sensible to store the + result in a local variable in suitable scope (e.g. method, class or jsp). + Most of the overhead comes from the use of the Java Reflection API, which is used to provide + information about annotations, fields and constructors. Some of the information is already cached + by the JVM and the library, so that only the first access gets a performance penalty.
diff --git a/src/docbkx/reference/programming-model/beanvalidation.xml b/src/docbkx/reference/programming-model/beanvalidation.xml index 344edef98..de0d6203d 100644 --- a/src/docbkx/reference/programming-model/beanvalidation.xml +++ b/src/docbkx/reference/programming-model/beanvalidation.xml @@ -11,8 +11,7 @@ Bean validation - Indexing entities - Fulltext indexing - Manual index usage - personIndex = gdc.getIndex(Person.class); diff --git a/src/docbkx/reference/programming-model/projection.xml b/src/docbkx/reference/programming-model/projection.xml index 07c1d6a2b..541c27c66 100644 --- a/src/docbkx/reference/programming-model/projection.xml +++ b/src/docbkx/reference/programming-model/projection.xml @@ -24,9 +24,9 @@ reporting or auditing) and only project them to a concrete, more functional target type when the business logic requires it. - + Projection of entities + + + diff --git a/src/docbkx/reference/programming-model/relationships.xml b/src/docbkx/reference/programming-model/relationships.xml index 083fe52de..4f89d62ec 100644 --- a/src/docbkx/reference/programming-model/relationships.xml +++ b/src/docbkx/reference/programming-model/relationships.xml @@ -24,8 +24,7 @@ Single relationship field - Node entity with relationships - Relationship entity - Accessing relationship entities using @RelatedToVia - roles; diff --git a/src/docbkx/reference/programming-model/repositories.xml b/src/docbkx/reference/programming-model/repositories.xml index 71cf38ecb..b41fdf552 100644 --- a/src/docbkx/reference/programming-model/repositories.xml +++ b/src/docbkx/reference/programming-model/repositories.xml @@ -132,28 +132,27 @@ Using GraphRepositories - graphRepository = graphRepositoryFactory - .createGraphRepository(Person.class); + graphRepository = graphRepositoryFactory + .createGraphRepository(Person.class); - Person michael = graphRepository.save(new Person("Michael", 36)); +Person michael = graphRepository.save(new Person("Michael", 36)); - Person dave = graphRepository.findOne(123); +Person dave = graphRepository.findOne(123); - Long numberOfPeople = graphRepository.count(); +Long numberOfPeople = graphRepository.count(); - Person mark = graphRepository.findByPropertyValue("name", "mark"); +Person mark = graphRepository.findByPropertyValue("name", "mark"); - Iterable devs = graphRepository.findAllByProperyValue("occupation", "developer"); +Iterable devs = graphRepository.findAllByProperyValue("occupation", "developer"); - Iterable middleAgedPeople = graphRepository.findAllByRange("age", 20, 40); +Iterable middleAgedPeople = graphRepository.findAllByRange("age", 20, 40); - Iterable aTeam = graphRepository.findAllByQuery("name", "A*"); +Iterable aTeam = graphRepository.findAllByQuery("name", "A*"); - Iterable davesFriends = graphRepository.findAllByTraversal(dave, - Traversal.description().pruneAfterDepth(1) - .relationships(KNOWS).filter(returnAllButStartNode())); - ]]> +Iterable davesFriends = graphRepository.findAllByTraversal(dave, + Traversal.description().pruneAfterDepth(1) + .relationships(KNOWS).filter(returnAllButStartNode())); +]]> @@ -167,8 +166,7 @@ Composing repositories - , PersonRepositoryExtension {} + , PersonRepositoryExtension {} // alternatively select some of the required repositories individually public interface PersonRepository extends CRUDGraphRepository, diff --git a/src/docbkx/reference/programming-model/transactions.xml b/src/docbkx/reference/programming-model/transactions.xml index 7a9d0da46..afb2dfe50 100644 --- a/src/docbkx/reference/programming-model/transactions.xml +++ b/src/docbkx/reference/programming-model/transactions.xml @@ -22,8 +22,7 @@ Simple transaction manager configuration - + @@ -47,8 +46,7 @@ Neo4j Spring integration - + @@ -78,8 +76,7 @@ ChainedTransactionManager example - diff --git a/src/docbkx/reference/setup.xml b/src/docbkx/reference/setup.xml index c9de55074..f09ad2665 100644 --- a/src/docbkx/reference/setup.xml +++ b/src/docbkx/reference/setup.xml @@ -2,210 +2,227 @@ Environment setup - To use Spring Data Graph in your application, some setup is required. For building the application the necessary Maven dependencies must be included and - for the AspectJ weaving some extensions of the compile goal are necessary. This chapter also discusses the Spring configuration needed to set up - Spring Data Graph. Examples for this setup can be found in the Spring Data Graph examples. + + Spring Data Graph dramatically simplifies development, but some setup is naturally required. + For building the application, Maven needs to be configured to include the Spring Data Graph dependencies, + and configure the AspectJ weaving. After the build setup is complete, the Spring application needs to be + configured to make use of Spring Data Graph. + + +
- Maven Configuration + Maven configuration - As stated in the requirements chapter, Spring Data Graph projects are easiest to build with Apache Maven. The main dependencies are Spring Data Graph itself, Spring Data Commons, some parts of the Spring Framework and of course the Neo4j graph database. + Spring Data Graph projects are easiest to build with Apache Maven. The main dependencies are: Spring + Data Graph itself, Spring Data Commons, parts of the Spring Framework, and the Neo4j graph database. +
- Repositories + Repositories - The milestone releases of Spring Data Graph are available from the dedicated milestone repository. Neo4j - releases and milestones are available from Maven Central. + The milestone releases of Spring Data Graph are available from the dedicated milestone + repository. Neo4j releases and milestones are available from Maven Central. - - spring-maven-milestone - Springframework Maven Repository - http://maven.springframework.org/milestone + + Spring milestone repository + + spring-maven-milestone + Springframework Maven Repository + http://maven.springframework.org/milestone - ]]> -
-
- Dependencies - The dependency on spring-data-neo4j - should transitively pull in Spring Framework (core, context, aop, - aspects, tx), Aspectj, Neo4j and Spring Data Commons. If you already use these (or different versions of - these) in your project, then include those dependencies on your own. - - - org.springframework.data - spring-data-neo4j - 1.0.0.RELEASE - - - - org.aspectj - aspectjrt - 1.6.11.RELEASE - - ]]> - +]]> +
-
- AspectJ build configuration - As Spring Data Graph uses AspectJ for build time aspect weaving of your entities, it is necessary to add the aspectj-plugin to the build phases. The plugin has its own dependencies. You also need to explicitely specifiy libraries containing aspects (spring-aspects and spring-data-neo4j) - - org.codehaus.mojo - aspectj-maven-plugin - 1.0 - - - - org.aspectj - aspectjrt - 1.6.11.RELEASE - - - org.aspectj - aspectjtools - 1.6.11.RELEASE - - - - - - compile - test-compile - - - - - true - - - org.springframework - spring-aspects - - - org.springframework.data - spring-datastore-neo4j - - - 1.6 - 1.6 - - - ]]> -
-
-
- Setting Up Spring Data Graph - Spring Configuration - The concrete configuration for Spring Data Graph is quite verbose as there is no autowiring involved. It sets up the following parts. - - - GraphDatabaseService for the embedded Neo4j storage engine - - - Spring transaction manager, Neo4j transaction manager - - - aspects and instantiators for node and relationship entities - - - EntityState and FieldAccessFactories needed for the different field handling - - - Conversion services - - - Repository support - - - TypeRepresentationStrategies - - - -
- XML-Namespace + Dependencies - To simplify the configuration we provide a xml namespace datagraph that allows configuration of any - Spring Data Graph project with a single line of xml code. There are three possible parameters. You can use storeDirectory - or the reference to graphDatabaseService alternatively. For cross-store configuration just refer - to an entityManagerFactory. + The dependency on spring-data-neo4j will transitively pull in the necessary parts of + Spring Framework (core, context, aop, aspects, tx), Aspectj, Neo4j, and Spring Data Commons. If you + already use these (or different versions of these) in your project, then include those dependencies + on your own. - + + Maven dependencies + + org.springframework.data + spring-data-neo4j + 1.0.0.RELEASE + + + + org.aspectj + aspectjrt + 1.6.11.RELEASE + +]]> + +
+ +
+ AspectJ build configuration + + Since Spring Data Graph uses AspectJ for build-time aspect weaving of entities, it is necessary to + hook in the AspectJ Maven plugin to the build process. The plugin also has its own dependencies. You + also need to explicitly specify the aspect libraries (spring-aspects and spring-data-neo4j). + + + AspectJ configuration + + org.codehaus.mojo + aspectj-maven-plugin + 1.0 + + + + org.aspectj + aspectjrt + 1.6.11.RELEASE + + + org.aspectj + aspectjtools + 1.6.11.RELEASE + + + + + + compile + test-compile + + + + + true + + + org.springframework + spring-aspects + + + org.springframework.data + spring-datastore-neo4j + + + 1.6 + 1.6 + + +]]> + +
+
+ +
+ Spring configuration + + Users of Spring Data Graph have two ways of very concisely configuring it. Either they can use a + Spring Data Graph XML configuration namespace, or they can use a Java-based bean configuration. + +
+ XML namespace + + The XML namespace can be used to configure Spring Data Graph. The config element + provides an XML-based configuration of Spring Data Graph in one line. It has three attributes. + graphDatabaseService points out the Neo4j instance to use. For convenience, + storeDirectory can be set instead of graphDatabaseService to + point to a directory where a new EmbeddedGraphDatabase will be created. For + cross-store configuration, the entityManagerFactory attribute needs to be + configured. + + + XML configuration with store directory + + xmlns:context="http://www.springframework.org/schema/context" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns:datagraph="http://www.springframework.org/schema/data/graph" + xsi:schemaLocation=" + http://www.springframework.org/schema/beans + http://www.springframework.org/schema/beans/spring-beans-3.0.xsd + http://www.springframework.org/schema/context + http://www.springframework.org/schema/context/spring-context-3.0.xsd + http://www.springframework.org/schema/data/graph + http://www.springframework.org/schema/data/graph/datagraph-1.0.xsd"> - ]]> - +]]> + + + XML configuration with bean + - - - + + + - - ]]> + +]]> + + + XML configuration with cross-store + - + + + + - - - - - - - ]]> + +]]> +
- Java based Configuration + Java-based bean configuration - You can also configure Spring Data Graph using Java based bean metadata. - For those not familiar with how to configure the Spring - container using Java based bean metadata instead of XML based metadata - see the high level introduction in the reference docs here as well as the detailed documentation here. - - -To help configure Spring Data Graph using Java based bean metadata the class Neo4jConfiguration is registerd with the context either explicitly in the XML config or via classpath scanning for classes that have the @Configuration annotation. The only thing that must be provided in addition is the GraphDatabaseService configured with a datastore directory. The example below shows using XML to register the Neo4jConfiguration @Configuration class as well as Spring's ConfigurationClassPostProcessor that transforms the @Configuration class to bean definitions. - - ... - - - - - - - - - - ... - - ]]> + You can also configure Spring Data Graph using Java-based bean metadata. + + + + For those not familiar with Java-based bean metadata in Spring, we recommend that you + read up on it first. The Spring documentation has a + high-level introduction + as well as + detailed documentation + on it. + + + In order to configure Spring Data Graph with Java-based bean metadata, the class + Neo4jConfiguration is registered with the context. This is either done + explicitly in the context configuration, or via classpath scanning for classes that + have the @Configuration annotation. The only thing that must be provided is the + GraphDatabaseService. The example below shows how to register the + @Configuration Neo4jConfiguration class, as well as Spring's + ConfigurationClassPostProcessor that transforms the + @Configuration class to bean definitions. + + Java-based bean configuration + + ... + + + + + + + + + ... + +]]> + + +
diff --git a/src/docbkx/reference/spring-data.xml b/src/docbkx/reference/spring-data.xml index d4a0c1fb5..70a755e30 100644 --- a/src/docbkx/reference/spring-data.xml +++ b/src/docbkx/reference/spring-data.xml @@ -6,6 +6,6 @@ Spring Data is a SpringSource project that aims to provide Spring's convenient programming model and well known conventions for NOSQL databases. Currently there is support for graph (e.g. Neo4j), key-value (e.g. Redis), document (e.g. MongoDB) and relational (e.g. Oracle) - databases. Mark Pollack, the author of Spring.NET is the project lead for the Spring Data project. + databases. Mark Pollack, the author of Spring.NET, is the project lead for the Spring Data project. diff --git a/src/docbkx/reference/template.xml b/src/docbkx/reference/template.xml index 601b44ee1..f977d5664 100644 --- a/src/docbkx/reference/template.xml +++ b/src/docbkx/reference/template.xml @@ -1,24 +1,26 @@ - Neo4jTemplate - - The Neo4jTemplate offers the convenient API of Spring templates for the Neo4j graph database. - It is initialized with a GraphDatabaseService which is thread-safe to use. - + Neo4jTemplate + + The Neo4jTemplate offers the convenient API of Spring templates for the Neo4j graph + database. +
Basic operations - For direct retrieval of nodes and relationships the getReferenceNode, getNode and - getRelationship can be used. + For direct retrieval of nodes and relationships, the getReferenceNode(), + getNode() and getRelationship() methods can be used. - There are methods (createNode and createRelationship) for creating nodes and + There are methods (createNode() and createRelationship()) for creating nodes and relationships that automatically set provided properties and optionally index certain fields. - - + Neo4j template + - +
Indexing - Adding nodes and relationships to an index is achieved using the index method. + Adding nodes and relationships to an index is done with the index() method. - Query methods either take a field / value combination to look for exact matches in the index or - a lucene query object or string to handle more complex queries. All query methods provide - Path results to a PathMapper. + The query() methods either take a field/value combination to look for exact matches in the + index, or a Lucene query object or string to handle more complex queries. All query() + methods provide Path results to a PathMapper.
- Traversal + Graph traversal - Traversal methods are at the core of graph operations. As such, they are fully supported in the - Neo4jTemplate. The traverseNext method traverses to the direct neighbours of the - start node filtering the relationships according to its parameters. + The traversal methods are at the core of graph operations. As such, they are fully supported in the + Neo4jTemplate. The traverseNext() method traverses to the direct neighbors + of the start node, filtering the relationships according to the parameters. - The traverse method covers the full traversal operation that takes a powerful - TraversalDescription (most probably built from the Traversal.description() - DSL) and runs it from the start node. Each path that is returned via the traversal is passed to the - PathMapper to be processed accordingly. + The traverse() method covers the full traversal operation that takes a + TraversalDescription (typically built with the Traversal.description() + DSL) and runs it from the start node. Each path that is returned by the traversal is passed to the + PathMapper to be converted into the desired type. -
Path abstraction and PathMapper For the querying operations Neo4jTemplate unifies the result with the Path abstraction that - comes from Neo4j. Much like a resultset a path contains nodes() and relationships() - starting at a startNode() and ending with aendNode(), the - lastRelationship() is also available separately. The Path abstraction also wraps - results that contain just nodes or relationships. + comes from Neo4j. Much like a result set, a path contains a chain of nodes() connected by + relationships(), starting at a startNode() and ending at a + endNode(). The lastRelationship() is also available separately. The + Path abstraction also wraps results that contain just nodes or relationships. - Using implementations of PathMapper<T> - and PathMapper.WithoutResult (comparable with RowMapper and - RowCallbackHandler) the paths can be converted to arbitrary Java objects. + Using implementations of PathMapper<T> and PathMapper.WithoutResult + (comparable with RowMapper and RowCallbackHandler), the paths can be converted + to arbitrary Java objects. - With EntityPath and EntityMapper there is also support for using annotation based - NodeEntities within the Path and PathMapper constructs. + With EntityPath and EntityMapper there is also support for using + node entities within the Path and PathMapper constructs.
- Transaction handling/management + Transactions - The Neo4jTemplate provides configurable implicit transactions for all its methods. By default - it creates a transaction for each call (which is a no-op if there is already a transaction running). If - you call the constructor with the useExplicitTransactions parameter set to true, it won't - create any transactions so you have to provide them using @Transactional or the TransactionTemplate. + The Neo4jTemplate provides configurable implicit transactions for all its methods. By + default it creates a transaction for each call (which is a no-op if there is already a transaction + running). If you call the constructor with the useExplicitTransactions parameter set to + true, it won't create any transactions so you have to provide them using @Transactional + or the TransactionTemplate.
diff --git a/src/docbkx/tutorial/annotations.xml b/src/docbkx/tutorial/annotations.xml index 7a77a617c..68d651837 100644 --- a/src/docbkx/tutorial/annotations.xml +++ b/src/docbkx/tutorial/annotations.xml @@ -29,8 +29,7 @@ First test case - Movie class - Domain model - JSON movie response - JSON actor response - Importing the data - Exact Indexing for Movie id - Neo4j Maven dependency - + org.neo4j neo4j 1.3.M05 @@ -41,8 +40,7 @@ Neo4j core API (transaction code omitted) - Recommendations - recommendMovies(User user, final int ratingDistance) { + recommendMovies(User user, final int ratingDistance) { final DynamicRelationshipType RATED = withName(User.RATED); final Map ratings=new HashMap(); TraversalDescription traversal= Traversal.description().breadthFirst() diff --git a/src/docbkx/tutorial/relationships.xml b/src/docbkx/tutorial/relationships.xml index 1cda800f5..16bb04a8c 100644 --- a/src/docbkx/tutorial/relationships.xml +++ b/src/docbkx/tutorial/relationships.xml @@ -19,8 +19,7 @@ Role class - Relating actors to movies - @RelatedTo usage - cast; + Set movies; public Role playedIn(Movie movie, String roleName) { Role role = relateTo(movie, Role.class, "ACTS_IN"); @@ -115,8 +112,7 @@ class Actor { @RelatedToVia usage - Movie repository - {} ]]> Then we added it to the Spring context configuration by simply adding: Repository context configuration - + ]]> We then created the domain-specific repository class, annotating it with @Repository and @@ -27,8 +25,7 @@ public interface MovieRepository extends GraphRepository {} Domain-specific repository - Populating the database - Controller - Populating the database - JSP - + <%@ taglib uri="http://www.springframework.org/tags" prefix="s" %> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> @@ -119,8 +117,7 @@ public class MovieController { Starting the Neo4j Shell - @@ -132,8 +129,7 @@ neo4j-shell -readonly -path data/graph.db Neo4j Shell usage - for info about each command. diff --git a/src/docbkx/tutorial/security.xml b/src/docbkx/tutorial/security.xml index 36b3cc02a..98ab8b54f 100644 --- a/src/docbkx/tutorial/security.xml +++ b/src/docbkx/tutorial/security.xml @@ -15,8 +15,7 @@ Spring Security pom.xml - + org.springframework.security spring-security-web ${spring.version} @@ -32,8 +31,7 @@ Spring Security web.xml - + contextConfigLocation /WEB-INF/applicationContext-security.xml @@ -60,8 +58,7 @@ Spring Security applicationContext-security.xml - + @@ -89,8 +86,7 @@ UserDetailsService and UserDetails implementation - Project pom.xml - + 3.0.5.RELEASE @@ -69,8 +68,7 @@ Project web.xml - + org.springframework.web.context.ContextLoaderListener @@ -99,8 +97,7 @@ Project applicationContext.xml - + Project dispatcherServlet-servlet.xml - + diff --git a/src/docbkx/tutorial/social.xml b/src/docbkx/tutorial/social.xml index 6d0302c4d..1a8a4ae37 100644 --- a/src/docbkx/tutorial/social.xml +++ b/src/docbkx/tutorial/social.xml @@ -18,8 +18,7 @@ Social entities - Populate users and ratings - populateDatabase() { Actor tomHanks = new Actor("1", "Tom Hanks").persist(); Movie forestGump = new Movie("1", "Forrest Gump").persist(); @@ -88,8 +86,7 @@ public List populateDatabase() { Getting the rating of a movie - Spring Data Graph Maven configuration - + 1.6.11.RELEASE @@ -85,8 +83,7 @@ Spring Data Graph context configuration - diff --git a/src/docbkx/tutorial/webapp.xml b/src/docbkx/tutorial/webapp.xml index d4073fb83..1b5a6b328 100644 --- a/src/docbkx/tutorial/webapp.xml +++ b/src/docbkx/tutorial/webapp.xml @@ -12,8 +12,7 @@ Controller for showing movies - Searching for movies - findMovies(String query, int count) { List movies=new ArrayList(count); @@ -79,8 +77,7 @@ public class CineastRepository { Search controller - movies = repository.findMovies(query, 20); model.addAttribute("movies", movies); @@ -93,8 +90,7 @@ public String findMovies(Model model, @RequestParam("q") String query) { Search Results JSP - Movies + Movies