update neo4j
This commit is contained in:
parent
f60debdcd3
commit
e0e6fbad2b
|
@ -37,18 +37,6 @@
|
|||
<groupId>org.springframework.data</groupId>
|
||||
<artifactId>spring-data-neo4j</artifactId>
|
||||
<version>${spring-data-neo4j.version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>commons-logging</artifactId>
|
||||
<groupId>commons-logging</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.data</groupId>
|
||||
<artifactId>spring-data-neo4j</artifactId>
|
||||
<version>${spring-data-neo4j.version}</version>
|
||||
<type>test-jar</type>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.voodoodyne.jackson.jsog</groupId>
|
||||
|
@ -86,6 +74,11 @@
|
|||
<version>${neo4j-ogm.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.neo4j</groupId>
|
||||
<artifactId>neo4j-ogm-embedded-driver</artifactId>
|
||||
<version>${neo4j-ogm.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.neo4j.test</groupId>
|
||||
<artifactId>neo4j-harness</artifactId>
|
||||
|
@ -96,23 +89,17 @@
|
|||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-test</artifactId>
|
||||
<version>${spring-test.version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>commons-logging</artifactId>
|
||||
<groupId>commons-logging</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<properties>
|
||||
<neo4j-java-driver.version>1.1.1</neo4j-java-driver.version>
|
||||
<neo4j.version>3.1.0</neo4j.version>
|
||||
<spring-data-neo4j.version>4.1.6.RELEASE</spring-data-neo4j.version>
|
||||
<neo4j-java-driver.version>1.6.2</neo4j-java-driver.version>
|
||||
<neo4j.version>3.4.6</neo4j.version>
|
||||
<spring-data-neo4j.version>5.0.1.RELEASE</spring-data-neo4j.version>
|
||||
<jackson-jsog.version>1.1</jackson-jsog.version>
|
||||
<spring-boot.version>1.5.13.RELEASE</spring-boot.version>
|
||||
<spring-test.version>4.3.17.RELEASE</spring-test.version>
|
||||
<neo4j-ogm.version>2.1.1</neo4j-ogm.version>
|
||||
<spring-boot.version>2.0.1.RELEASE</spring-boot.version>
|
||||
<spring-test.version>5.0.1.RELEASE</spring-test.version>
|
||||
<neo4j-ogm.version>3.1.2</neo4j-ogm.version>
|
||||
</properties>
|
||||
|
||||
</project>
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.baeldung.spring.data.neo4j.config;
|
||||
|
||||
import org.neo4j.ogm.config.Configuration.Builder;
|
||||
import org.neo4j.ogm.session.SessionFactory;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
|
@ -8,15 +9,14 @@ import org.springframework.data.neo4j.repository.config.EnableNeo4jRepositories;
|
|||
|
||||
@ComponentScan(basePackages = { "com.baeldung.spring.data.neo4j.services" })
|
||||
@Configuration
|
||||
@EnableNeo4jRepositories(basePackages = "com.baeldung.spring.data.neo4j.repostory")
|
||||
@EnableNeo4jRepositories(basePackages = "com.baeldung.spring.data.neo4j.repository")
|
||||
public class MovieDatabaseNeo4jConfiguration {
|
||||
|
||||
public static final String URL = System.getenv("NEO4J_URL") != null ? System.getenv("NEO4J_URL") : "http://neo4j:movies@localhost:7474";
|
||||
|
||||
@Bean
|
||||
public org.neo4j.ogm.config.Configuration getConfiguration() {
|
||||
org.neo4j.ogm.config.Configuration config = new org.neo4j.ogm.config.Configuration();
|
||||
config.driverConfiguration().setDriverClassName("org.neo4j.ogm.drivers.http.driver.HttpDriver").setURI(URL);
|
||||
org.neo4j.ogm.config.Configuration config = new Builder().uri(URL).build();
|
||||
return config;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,26 +1,25 @@
|
|||
package com.baeldung.spring.data.neo4j.config;
|
||||
|
||||
import org.neo4j.ogm.config.Configuration.Builder;
|
||||
import org.neo4j.ogm.session.SessionFactory;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Profile;
|
||||
import org.springframework.data.neo4j.config.Neo4jConfiguration;
|
||||
import org.springframework.data.neo4j.repository.config.EnableNeo4jRepositories;
|
||||
import org.springframework.data.neo4j.transaction.Neo4jTransactionManager;
|
||||
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||
|
||||
@Configuration
|
||||
@EnableTransactionManagement
|
||||
@ComponentScan(basePackages = { "com.baeldung.spring.data.neo4j.services" })
|
||||
@EnableNeo4jRepositories(basePackages = "com.baeldung.spring.data.neo4j.repostory")
|
||||
@EnableNeo4jRepositories(basePackages = "com.baeldung.spring.data.neo4j.repository")
|
||||
@Profile({ "embedded", "test" })
|
||||
public class MovieDatabaseNeo4jTestConfiguration extends Neo4jConfiguration {
|
||||
public class MovieDatabaseNeo4jTestConfiguration {
|
||||
|
||||
@Bean
|
||||
public org.neo4j.ogm.config.Configuration getConfiguration() {
|
||||
final org.neo4j.ogm.config.Configuration config = new org.neo4j.ogm.config.Configuration();
|
||||
config.driverConfiguration()
|
||||
.setDriverClassName("org.neo4j.ogm.drivers.embedded.driver.EmbeddedDriver");
|
||||
org.neo4j.ogm.config.Configuration config = new Builder().build();
|
||||
return config;
|
||||
}
|
||||
|
||||
|
@ -28,5 +27,10 @@ public class MovieDatabaseNeo4jTestConfiguration extends Neo4jConfiguration {
|
|||
public SessionFactory getSessionFactory() {
|
||||
return new SessionFactory(getConfiguration(), "com.baeldung.spring.data.neo4j.domain");
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Neo4jTransactionManager transactionManager() {
|
||||
return new Neo4jTransactionManager(getSessionFactory());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
package com.baeldung.spring.data.neo4j.domain;
|
||||
|
||||
import org.neo4j.ogm.annotation.GraphId;
|
||||
import org.neo4j.ogm.annotation.GeneratedValue;
|
||||
import org.neo4j.ogm.annotation.Id;
|
||||
import org.neo4j.ogm.annotation.NodeEntity;
|
||||
import org.neo4j.ogm.annotation.Relationship;
|
||||
|
||||
@NodeEntity
|
||||
public class Car {
|
||||
@GraphId
|
||||
@Id @GeneratedValue
|
||||
private Long id;
|
||||
|
||||
private String make;
|
||||
|
|
|
@ -2,7 +2,9 @@ package com.baeldung.spring.data.neo4j.domain;
|
|||
|
||||
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
|
||||
import com.voodoodyne.jackson.jsog.JSOGGenerator;
|
||||
import org.neo4j.ogm.annotation.GraphId;
|
||||
|
||||
import org.neo4j.ogm.annotation.GeneratedValue;
|
||||
import org.neo4j.ogm.annotation.Id;
|
||||
import org.neo4j.ogm.annotation.NodeEntity;
|
||||
import org.neo4j.ogm.annotation.Relationship;
|
||||
|
||||
|
@ -13,7 +15,7 @@ import java.util.List;
|
|||
|
||||
@NodeEntity
|
||||
public class Movie {
|
||||
@GraphId
|
||||
@Id @GeneratedValue
|
||||
Long id;
|
||||
|
||||
private String title;
|
||||
|
|
|
@ -2,7 +2,9 @@ package com.baeldung.spring.data.neo4j.domain;
|
|||
|
||||
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
|
||||
import com.voodoodyne.jackson.jsog.JSOGGenerator;
|
||||
import org.neo4j.ogm.annotation.GraphId;
|
||||
|
||||
import org.neo4j.ogm.annotation.GeneratedValue;
|
||||
import org.neo4j.ogm.annotation.Id;
|
||||
import org.neo4j.ogm.annotation.NodeEntity;
|
||||
import org.neo4j.ogm.annotation.Relationship;
|
||||
|
||||
|
@ -11,7 +13,7 @@ import java.util.List;
|
|||
@JsonIdentityInfo(generator = JSOGGenerator.class)
|
||||
@NodeEntity
|
||||
public class Person {
|
||||
@GraphId
|
||||
@Id @GeneratedValue
|
||||
Long id;
|
||||
|
||||
private String name;
|
||||
|
|
|
@ -3,7 +3,8 @@ package com.baeldung.spring.data.neo4j.domain;
|
|||
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
|
||||
import com.voodoodyne.jackson.jsog.JSOGGenerator;
|
||||
import org.neo4j.ogm.annotation.EndNode;
|
||||
import org.neo4j.ogm.annotation.GraphId;
|
||||
import org.neo4j.ogm.annotation.GeneratedValue;
|
||||
import org.neo4j.ogm.annotation.Id;
|
||||
import org.neo4j.ogm.annotation.RelationshipEntity;
|
||||
import org.neo4j.ogm.annotation.StartNode;
|
||||
|
||||
|
@ -12,8 +13,8 @@ import java.util.Collection;
|
|||
@JsonIdentityInfo(generator = JSOGGenerator.class)
|
||||
@RelationshipEntity(type = "ACTED_IN")
|
||||
public class Role {
|
||||
@GraphId
|
||||
Long id;
|
||||
@Id @GeneratedValue
|
||||
Long id;
|
||||
private Collection<String> roles;
|
||||
@StartNode
|
||||
private Person person;
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package com.baeldung.spring.data.neo4j.repostory;
|
||||
package com.baeldung.spring.data.neo4j.repository;
|
||||
|
||||
import com.baeldung.spring.data.neo4j.domain.Movie;
|
||||
import org.springframework.data.neo4j.annotation.Query;
|
||||
import org.springframework.data.neo4j.repository.GraphRepository;
|
||||
import org.springframework.data.neo4j.repository.Neo4jRepository;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
|
@ -11,7 +11,7 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
|
||||
@Repository
|
||||
public interface MovieRepository extends GraphRepository<Movie> {
|
||||
public interface MovieRepository extends Neo4jRepository<Movie, Long> {
|
||||
|
||||
Movie findByTitle(@Param("title") String title);
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
package com.baeldung.spring.data.neo4j.repository;
|
||||
|
||||
import com.baeldung.spring.data.neo4j.domain.Person;
|
||||
import org.springframework.data.neo4j.repository.Neo4jRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public interface PersonRepository extends Neo4jRepository<Person, Long> {
|
||||
}
|
|
@ -1,9 +0,0 @@
|
|||
package com.baeldung.spring.data.neo4j.repostory;
|
||||
|
||||
import com.baeldung.spring.data.neo4j.domain.Person;
|
||||
import org.springframework.data.neo4j.repository.GraphRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public interface PersonRepository extends GraphRepository<Person> {
|
||||
}
|
|
@ -1,10 +1,11 @@
|
|||
package com.baeldung.spring.data.neo4j.services;
|
||||
|
||||
import com.baeldung.spring.data.neo4j.repostory.MovieRepository;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import com.baeldung.spring.data.neo4j.repository.MovieRepository;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@Service
|
||||
|
|
|
@ -12,14 +12,12 @@ import org.neo4j.ogm.session.SessionFactory;
|
|||
|
||||
import com.baeldung.spring.data.neo4j.domain.Car;
|
||||
import com.baeldung.spring.data.neo4j.domain.Company;
|
||||
import org.neo4j.ogm.transaction.Transaction;
|
||||
|
||||
public class Neo4jOgmLiveTest {
|
||||
|
||||
@Test
|
||||
public void testOgm() {
|
||||
Configuration conf = new Configuration();
|
||||
conf.driverConfiguration().setDriverClassName("org.neo4j.ogm.drivers.embedded.driver.EmbeddedDriver");
|
||||
Configuration conf =new Configuration.Builder().build();
|
||||
|
||||
SessionFactory factory = new SessionFactory(conf, "com.baeldung.spring.data.neo4j.domain");
|
||||
Session session = factory.openSession();
|
||||
|
|
|
@ -4,8 +4,9 @@ import com.baeldung.spring.data.neo4j.config.MovieDatabaseNeo4jTestConfiguration
|
|||
import com.baeldung.spring.data.neo4j.domain.Movie;
|
||||
import com.baeldung.spring.data.neo4j.domain.Person;
|
||||
import com.baeldung.spring.data.neo4j.domain.Role;
|
||||
import com.baeldung.spring.data.neo4j.repostory.MovieRepository;
|
||||
import com.baeldung.spring.data.neo4j.repostory.PersonRepository;
|
||||
import com.baeldung.spring.data.neo4j.repository.MovieRepository;
|
||||
import com.baeldung.spring.data.neo4j.repository.PersonRepository;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
@ -50,10 +51,10 @@ public class MovieRepositoryIntegrationTest {
|
|||
Role charlie = new Role();
|
||||
charlie.setMovie(italianJob);
|
||||
charlie.setPerson(mark);
|
||||
Collection<String> roleNames = new HashSet();
|
||||
Collection<String> roleNames = new HashSet<>();
|
||||
roleNames.add("Charlie Croker");
|
||||
charlie.setRoles(roleNames);
|
||||
List<Role> roles = new ArrayList();
|
||||
List<Role> roles = new ArrayList<>();
|
||||
roles.add(charlie);
|
||||
italianJob.setRoles(roles);
|
||||
movieRepository.save(italianJob);
|
||||
|
|
Loading…
Reference in New Issue