@ -3726,7 +3726,7 @@ considered. A typical entity class resembles the following example:
@@ -3726,7 +3726,7 @@ considered. A typical entity class resembles the following example:
public City(String name, String state) {
this.name = name;
this.country = country;
this.state = state;
}
public String getName() {
@ -3778,7 +3778,7 @@ The following example shows a typical Spring Data repository interface definitio
@@ -3778,7 +3778,7 @@ The following example shows a typical Spring Data repository interface definitio
Page<City> findAll(Pageable pageable);
City findByNameAndCountryAllIgnoringCase(String name, String country);
City findByNameAndStateAllIgnoringCase(String name, String state);
}
----
@ -4189,7 +4189,7 @@ in the following example:
@@ -4189,7 +4189,7 @@ in the following example:
Page<City> findAll(Pageable pageable);
City findByNameAndCountryAllIgnoringCase(String name, String country);
City findByNameAndStateAllIgnoringCase(String name, String state);
}
----
@ -4228,29 +4228,30 @@ the Mongo instance's configuration and logging routing.
@@ -4228,29 +4228,30 @@ the Mongo instance's configuration and logging routing.
[[boot-features-neo4j]]
=== Neo4j
http://neo4j.com/[Neo4j] is an open-source NoSQL graph database that uses a rich data
model of nodes related by first class relationships, which is better suited for connected
big data than traditional rdbms approaches. Spring Boot offers several conveniences for
working with Neo4j, including the `spring-boot-starter-data-neo4j` "`Starter`".
model of nodes connected by first class relationships, which is better suited for
connected big data than traditional RDBMS approaches. Spring Boot offers several
conveniences for working with Neo4j, including the `spring-boot-starter-data-neo4j`
"`Starter`".
[[boot-features-connecting-to-neo4j]]
==== Connecting to a Neo4j Database
You can inject an auto-configured `Neo4jSession`, `Session`, or `Neo4jOperations`
instance as you would any other Spring Bean. By default, the instance tries to connect to
a Neo4j server at `localhost:7474`. The following example shows how to inject a Neo4j
bean:
To access a Neo4j server, you can inject an auto-configured
`org.neo4j.ogm.session.Session`. By default, the instance tries to connect to a Neo4j
server at `localhost:7687` using the Bolt protocol. The following example shows how to
You can enable persistence for the embedded mode by providing a path to a database file
in your configuration, e.g. `spring.data.neo4j.uri=file://var/tmp/graph.db`.
====
[[boot-features-neo4j-ogm-session]]
==== Neo4jSession
By default, if you are running a web application, the session is bound to the thread for
the entire processing of the request (that is, it uses the "Open Session in View"
pattern). If you do not want this behavior, add the following line to your
@ -4316,42 +4323,32 @@ pattern). If you do not want this behavior, add the following line to your
@@ -4316,42 +4323,32 @@ pattern). If you do not want this behavior, add the following line to your
==== Spring Data Neo4j Repositories
Spring Data includes repository support for Neo4j.
In fact, both Spring Data JPA and Spring Data Neo4j share the same common infrastructure.
You could take the JPA example from earlier and, assuming that `City` is now a Neo4j OGM
`@NodeEntity` rather than a JPA `@Entity`, it works in the same way.
TIP: You can customize entity scanning locations by using the `@EntityScan` annotation.
To enable repository support (and optionally support for `@Transactional`), add the
following two annotations to your Spring configuration: