@@ -3554,7 +3554,7 @@ considered. A typical entity class resembles the following example:
35543554
35553555 public City(String name, String state) {
35563556 this.name = name;
3557- this.country = country ;
3557+ this.state = state ;
35583558 }
35593559
35603560 public String getName() {
@@ -3606,7 +3606,7 @@ The following example shows a typical Spring Data repository interface definitio
36063606
36073607 Page<City> findAll(Pageable pageable);
36083608
3609- City findByNameAndCountryAllIgnoringCase (String name, String country );
3609+ City findByNameAndStateAllIgnoringCase (String name, String state );
36103610
36113611 }
36123612----
@@ -4006,7 +4006,7 @@ in the following example:
40064006
40074007 Page<City> findAll(Pageable pageable);
40084008
4009- City findByNameAndCountryAllIgnoringCase (String name, String country );
4009+ City findByNameAndStateAllIgnoringCase (String name, String state );
40104010
40114011 }
40124012----
@@ -4045,75 +4045,82 @@ the Mongo instance's configuration and logging routing.
40454045[[boot-features-neo4j]]
40464046=== Neo4j
40474047http://neo4j.com/[Neo4j] is an open-source NoSQL graph database that uses a rich data
4048- model of nodes related by first class relationships, which is better suited for connected
4049- big data than traditional rdbms approaches. Spring Boot offers several conveniences for
4048+ model of nodes connected by first class relationships, which is better suited for connected
4049+ big data than traditional RDBMS approaches. Spring Boot offers several conveniences for
40504050working with Neo4j, including the `spring-boot-starter-data-neo4j` "`Starter`".
40514051
40524052
40534053
40544054[[boot-features-connecting-to-neo4j]]
40554055==== Connecting to a Neo4j Database
4056- You can inject an auto-configured `Neo4jSession`, `Session`, or `Neo4jOperations`
4057- instance as you would any other Spring Bean. By default, the instance tries to connect to
4058- a Neo4j server at `localhost:7474`. The following example shows how to inject a Neo4j
4059- bean:
4056+ To access a Neo4j server, you can inject an auto-configured `org.neo4j.ogm.session.Session`.
4057+ By default, the instance tries to connect to a Neo4j server at `localhost:7687` via the Bolt
4058+ protocol. The following example shows how to inject a Neo4j session:
40604059
40614060[source,java,indent=0]
40624061----
40634062 @Component
40644063 public class MyBean {
40654064
4066- private final Neo4jTemplate neo4jTemplate ;
4065+ private final Session session ;
40674066
40684067 @Autowired
4069- public MyBean(Neo4jTemplate neo4jTemplate ) {
4070- this.neo4jTemplate = neo4jTemplate ;
4068+ public MyBean(Session session ) {
4069+ this.session = session ;
40714070 }
40724071
40734072 // ...
40744073
40754074 }
40764075----
40774076
4078- You can take full control of the configuration by adding a
4079- `org.neo4j.ogm.config.Configuration` `@Bean` of your own. Also, adding a `@Bean` of type
4080- `Neo4jOperations` disables the auto-configuration.
4081-
4082- You can configure the user and credentials to use by setting the `spring.data.neo4j.*`
4077+ You can configure the uri and credentials to use by setting the `spring.data.neo4j.*`
40834078properties, as shown in the following example:
40844079
40854080[source,properties,indent=0]
40864081----
4087- spring.data.neo4j.uri=http ://my-server:7474
4082+ spring.data.neo4j.uri=bolt ://my-server:7687
40884083 spring.data.neo4j.username=neo4j
40894084 spring.data.neo4j.password=secret
40904085----
40914086
4087+ You can take full control over the session creation by adding a
4088+ `org.neo4j.ogm.config.Configuration` `@Bean`. To completely disable the auto-configuration
4089+ provided by the "`Starter`" , add a `@Bean` of type `org.neo4j.ogm.session.SessionFactory`.
4090+
40924091
40934092
40944093[[boot-features-connecting-to-neo4j-embedded]]
40954094==== Using the Embedded Mode
40964095
40974096If you add `org.neo4j:neo4j-ogm-embedded-driver` to the dependencies of your application,
40984097Spring Boot automatically configures an in-process embedded instance of Neo4j that does
4099- not persist any data when your application shuts down. You can explicitly disable that
4100- mode by setting `spring.data.neo4j.embedded.enabled=false`. You can also enable
4101- persistence for the embedded mode by providing a path to a database file, as shown in the
4102- following example:
4098+ not persist any data when your application shuts down.
41034099
4104- ----
4105- spring.data.neo4j.uri=file://var/tmp/graph.db
4106- ----
4100+ [NOTE]
4101+ ====
4102+ As the embedded Neo4j OGM driver does not provide the Neo4j kernel itself, you have
4103+ to declare `org.neo4j:neo4j` as dependency yourself. Refer to
4104+ https://neo4j.com/docs/ogm-manual/current/reference/#reference:getting-started[the
4105+ Neo4j OGM documentation] for list of compatible versions.
4106+ ====
4107+
4108+ The embedded driver takes precedence over the other drivers when there are multiple
4109+ drivers on the classpath. You can explicitly disable the embedded mode by setting
4110+ `spring.data.neo4j.embedded.enabled=false`.
4111+
4112+ <<boot-features-testing-spring-boot-applications-testing-autoconfigured-neo4j-test,Data Neo4j Tests>>
4113+ automatically make use of an embedded Neo4j instance if the embedded driver and Neo4j
4114+ kernel are on the classpath as described above.
41074115
41084116[NOTE]
41094117====
4110- The Neo4j OGM embedded driver does not provide the Neo4j kernel. Users are expected to
4111- provide this dependency manually. See
4112- http://neo4j.com/docs/ogm-manual/current/reference/#reference:getting-started[the
4113- documentation] for more details.
4118+ You can enable persistence for the embedded mode by providing a path to a database file
4119+ in your configuration like this: `spring.data.neo4j.uri=file://var/tmp/graph.db`.
41144120====
41154121
41164122
4123+
41174124[[boot-features-neo4j-ogm-session]]
41184125==== Neo4jSession
41194126
@@ -4133,44 +4140,34 @@ pattern). If you do not want this behavior, add the following line to your
41334140==== Spring Data Neo4j Repositories
41344141Spring Data includes repository support for Neo4j.
41354142
4136- In fact, both Spring Data JPA and Spring Data Neo4j share the same common infrastructure.
4137- You could take the JPA example from earlier and, assuming that `City` is now a Neo4j OGM
4138- `@NodeEntity` rather than a JPA `@Entity`, it works in the same way.
4139-
4140- TIP: You can customize entity scanning locations by using the `@EntityScan` annotation.
4141-
4142- To enable repository support (and optionally support for `@Transactional`), add the
4143- following two annotations to your Spring configuration:
4144-
4145- [source,java,indent=0]
4146- ----
4147- @EnableNeo4jRepositories(basePackages = "com.example.myapp.repository")
4148- @EnableTransactionManagement
4149- ----
4150-
4151- ==== Repository Example
4152-
4153- The following example shows an interface definition for a Neo4j repository:
4143+ Spring Data Neo4j shares the common infrastructure with Spring Data JPA as many other
4144+ Spring Data modules do. You could take the JPA example from earlier and define
4145+ `City` as Neo4j OGM `@NodeEntity` rather than JPA `@Entity` and the repository
4146+ abstraction works in the same way, as shown in the following example:
41544147
41554148[source,java,indent=0]
41564149----
41574150 package com.example.myapp.domain;
41584151
4159- import org.springframework.data.domain.*;
4160- import org.springframework.data.repository.*;
4152+ import java.util.Optional;
41614153
4162- public interface CityRepository extends GraphRepository<City> {
4154+ import org.springframework.data.neo4j.repository.*;
41634155
4164- Page <City> findAll(Pageable pageable);
4156+ public interface CityRepository extends Neo4jRepository <City, Long> {
41654157
4166- City findByNameAndCountry (String name, String country );
4158+ Optional< City> findOneByNameAndState (String name, String state );
41674159
41684160 }
41694161----
41704162
4171- TIP: For complete details of Spring Data Neo4j, including its rich object mapping
4172- technologies, refer to the https://projects.spring.io/spring-data-neo4j/[reference
4173- documentation].
4163+ The `spring-boot-starter-data-neo4j` "`Starter`" enables the repository support as well
4164+ as transaction management. You can customize the locations to look for repositories and
4165+ entities by using `@EnableNeo4jRepositories` and `@EntityScan` respectively on a
4166+ `@Configuration`-bean.
4167+
4168+ TIP: For complete details of Spring Data Neo4j, including its object mapping
4169+ technologies, refer to the https://projects.spring.io/spring-data-neo4j/[project page] and
4170+ the reference documentation.
41744171
41754172
41764173
0 commit comments