Skip to content

Commit 5de999f

Browse files
authored
Merge pull request eugenp#14241 from timis1/JAVA-22364
JAVA-22364 Split spring-data-neo4j module
2 parents 53b48ab + bbdd103 commit 5de999f

File tree

17 files changed

+710
-174
lines changed

17 files changed

+710
-174
lines changed

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,4 +120,7 @@ libraries-2/src/test/resources/crawler4j/**
120120
devDb*.db
121121

122122
#jaxb
123-
*.xjb
123+
*.xjb
124+
125+
#neo4j
126+
persistence-modules/neo4j/data/**
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
## Spring Data Neo4j
2+
3+
### Relevant Articles:
4+
- [A Guide to Neo4J with Java](https://www.baeldung.com/java-neo4j)
5+
6+
### Build the Project with Tests Running
7+
```
8+
mvn clean install
9+
```
10+
11+
### Run Tests Directly
12+
```
13+
mvn test
14+
```
15+

persistence-modules/neo4j/pom.xml

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
<artifactId>neo4j</artifactId>
7+
<version>1.0</version>
8+
<name>neo4j</name>
9+
10+
<parent>
11+
<groupId>com.baeldung</groupId>
12+
<artifactId>persistence-modules</artifactId>
13+
<version>1.0.0-SNAPSHOT</version>
14+
</parent>
15+
16+
<dependencies>
17+
<dependency>
18+
<groupId>org.neo4j</groupId>
19+
<artifactId>neo4j</artifactId>
20+
<version>${neo4j.version}</version>
21+
</dependency>
22+
<dependency>
23+
<groupId>org.neo4j</groupId>
24+
<artifactId>neo4j-ogm-core</artifactId>
25+
<version>${neo4j-ogm-core.version}</version>
26+
</dependency>
27+
<dependency>
28+
<groupId>org.neo4j</groupId>
29+
<artifactId>neo4j-ogm-embedded-driver</artifactId>
30+
<version>${neo4j-ogm-embedded.version}</version>
31+
</dependency>
32+
<dependency>
33+
<groupId>org.neo4j</groupId>
34+
<artifactId>neo4j-ogm-bolt-driver</artifactId>
35+
<version>${neo4j-ogm-bolt-driver.version}</version>
36+
</dependency>
37+
<dependency>
38+
<groupId>org.neo4j.driver</groupId>
39+
<artifactId>neo4j-java-driver</artifactId>
40+
<version>${neo4j-java-driver.version}</version>
41+
</dependency>
42+
<dependency>
43+
<groupId>org.neo4j</groupId>
44+
<artifactId>neo4j-jdbc-driver</artifactId>
45+
<version>${neo4j-jdbc.version}</version>
46+
<scope>runtime</scope>
47+
</dependency>
48+
<dependency>
49+
<groupId>com.voodoodyne.jackson.jsog</groupId>
50+
<artifactId>jackson-jsog</artifactId>
51+
<version>${jackson-jsog.version}</version>
52+
<scope>compile</scope>
53+
</dependency>
54+
<dependency>
55+
<groupId>org.neo4j</groupId>
56+
<artifactId>neo4j-kernel</artifactId>
57+
<version>${neo4j.version}</version>
58+
<type>test-jar</type>
59+
</dependency>
60+
<dependency>
61+
<groupId>org.neo4j.app</groupId>
62+
<artifactId>neo4j-server</artifactId>
63+
<version>${neo4j.version}</version>
64+
<type>test-jar</type>
65+
<exclusions>
66+
<exclusion>
67+
<artifactId>commons-logging</artifactId>
68+
<groupId>commons-logging</groupId>
69+
</exclusion>
70+
</exclusions>
71+
</dependency>
72+
<dependency>
73+
<groupId>org.neo4j</groupId>
74+
<artifactId>neo4j-ogm-test</artifactId>
75+
<version>${neo4j-ogm.version}</version>
76+
<scope>test</scope>
77+
</dependency>
78+
<dependency>
79+
<groupId>org.neo4j.test</groupId>
80+
<artifactId>neo4j-harness</artifactId>
81+
<version>${neo4j.version}</version>
82+
<scope>test</scope>
83+
</dependency>
84+
<dependency>
85+
<groupId>org.testcontainers</groupId>
86+
<artifactId>neo4j</artifactId>
87+
<version>${testcontainers.version}</version>
88+
<scope>test</scope>
89+
<exclusions>
90+
<exclusion>
91+
<groupId>org.jetbrains</groupId>
92+
<artifactId>annotations</artifactId>
93+
</exclusion>
94+
<exclusion>
95+
<groupId>org.apache.commons</groupId>
96+
<artifactId>commons-compress</artifactId>
97+
</exclusion>
98+
<exclusion>
99+
<groupId>javax.xml.bind</groupId>
100+
<artifactId>jaxb-api</artifactId>
101+
</exclusion>
102+
</exclusions>
103+
</dependency>
104+
</dependencies>
105+
106+
<properties>
107+
<neo4j-java-driver.version>5.6.0</neo4j-java-driver.version>
108+
<neo4j.version>5.8.0</neo4j.version>
109+
<jackson-jsog.version>1.1.2</jackson-jsog.version>
110+
<neo4j-ogm.version>3.1.22</neo4j-ogm.version>
111+
<neo4j-ogm-core.version>4.0.5</neo4j-ogm-core.version>
112+
<neo4j-ogm-embedded.version>3.2.39</neo4j-ogm-embedded.version>
113+
<neo4j-jdbc.version>4.0.9</neo4j-jdbc.version>
114+
<neo4j-ogm-bolt-driver.version>4.0.5</neo4j-ogm-bolt-driver.version>
115+
</properties>
116+
117+
</project>
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
package com.baeldung.neo4j.domain;
2+
3+
import static org.neo4j.ogm.annotation.Relationship.Direction.INCOMING;
4+
5+
import org.neo4j.ogm.annotation.GeneratedValue;
6+
import org.neo4j.ogm.annotation.Id;
7+
import org.neo4j.ogm.annotation.NodeEntity;
8+
import org.neo4j.ogm.annotation.Relationship;
9+
10+
@NodeEntity
11+
public class Car {
12+
@Id @GeneratedValue
13+
private Long id;
14+
15+
private String make;
16+
17+
@Relationship(direction = INCOMING)
18+
private Company company;
19+
20+
public Car(String make, String model) {
21+
this.make = make;
22+
this.model = model;
23+
}
24+
25+
public Long getId() {
26+
return id;
27+
}
28+
29+
public void setId(Long id) {
30+
this.id = id;
31+
}
32+
33+
public String getMake() {
34+
return make;
35+
}
36+
37+
public void setMake(String make) {
38+
this.make = make;
39+
}
40+
41+
public String getModel() {
42+
return model;
43+
}
44+
45+
public void setModel(String model) {
46+
this.model = model;
47+
}
48+
49+
private String model;
50+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
package com.baeldung.neo4j.domain;
2+
3+
import org.neo4j.ogm.annotation.NodeEntity;
4+
import org.neo4j.ogm.annotation.Relationship;
5+
6+
@NodeEntity
7+
public class Company {
8+
private Long id;
9+
10+
private String name;
11+
12+
@Relationship(type="owns")
13+
private Car car;
14+
15+
public Company(String name) {
16+
this.name = name;
17+
}
18+
19+
public Long getId() {
20+
return id;
21+
}
22+
23+
public void setId(Long id) {
24+
this.id = id;
25+
}
26+
27+
public String getName() {
28+
return name;
29+
}
30+
31+
public void setName(String name) {
32+
this.name = name;
33+
}
34+
35+
public Car getCar() {
36+
return car;
37+
}
38+
39+
public void setCar(Car car) {
40+
this.car = car;
41+
}
42+
}
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
package com.baeldung.neo4j.domain;
2+
3+
import static org.neo4j.ogm.annotation.Relationship.Direction.INCOMING;
4+
5+
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
6+
import com.voodoodyne.jackson.jsog.JSOGGenerator;
7+
8+
import org.neo4j.ogm.annotation.GeneratedValue;
9+
import org.neo4j.ogm.annotation.Id;
10+
import org.neo4j.ogm.annotation.NodeEntity;
11+
import org.neo4j.ogm.annotation.Relationship;
12+
13+
import java.util.Collection;
14+
import java.util.List;
15+
16+
@JsonIdentityInfo(generator = JSOGGenerator.class)
17+
18+
@NodeEntity
19+
public class Movie {
20+
@Id @GeneratedValue
21+
Long id;
22+
23+
private String title;
24+
25+
private int released;
26+
private String tagline;
27+
28+
@Relationship(type = "ACTED_IN", direction = INCOMING)
29+
private List<Role> roles;
30+
31+
public Movie() {
32+
}
33+
34+
public String getTitle() {
35+
return title;
36+
}
37+
38+
public int getReleased() {
39+
return released;
40+
}
41+
42+
public String getTagline() {
43+
return tagline;
44+
}
45+
46+
public Collection<Role> getRoles() {
47+
return roles;
48+
}
49+
50+
public void setTitle(String title) {
51+
this.title = title;
52+
}
53+
54+
public void setReleased(int released) {
55+
this.released = released;
56+
}
57+
58+
public void setTagline(String tagline) {
59+
this.tagline = tagline;
60+
}
61+
62+
public void setRoles(List<Role> roles) {
63+
this.roles = roles;
64+
}
65+
66+
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
package com.baeldung.neo4j.domain;
2+
3+
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
4+
import com.voodoodyne.jackson.jsog.JSOGGenerator;
5+
6+
import org.neo4j.ogm.annotation.GeneratedValue;
7+
import org.neo4j.ogm.annotation.Id;
8+
import org.neo4j.ogm.annotation.NodeEntity;
9+
import org.neo4j.ogm.annotation.Relationship;
10+
11+
import java.util.List;
12+
13+
@JsonIdentityInfo(generator = JSOGGenerator.class)
14+
@NodeEntity
15+
public class Person {
16+
@Id @GeneratedValue
17+
Long id;
18+
19+
private String name;
20+
private int born;
21+
22+
@Relationship(type = "ACTED_IN")
23+
private List<Movie> movies;
24+
25+
public Person() {
26+
}
27+
28+
public String getName() {
29+
return name;
30+
}
31+
32+
public int getBorn() {
33+
return born;
34+
}
35+
36+
public List<Movie> getMovies() {
37+
return movies;
38+
}
39+
40+
public void setName(String name) {
41+
this.name = name;
42+
}
43+
44+
public void setBorn(int born) {
45+
this.born = born;
46+
}
47+
48+
public void setMovies(List<Movie> movies) {
49+
this.movies = movies;
50+
}
51+
52+
}

0 commit comments

Comments
 (0)