File tree 6 files changed +40
-25
lines changed
src/main/java/org/neo4j/tips/sdn/sdn6_rest
6 files changed +40
-25
lines changed Original file line number Diff line number Diff line change 5
5
<parent >
6
6
<groupId >org.springframework.boot</groupId >
7
7
<artifactId >spring-boot-starter-parent</artifactId >
8
- <version >2.6.4 </version >
8
+ <version >2.7.0-M2 </version >
9
9
<relativePath /> <!-- lookup parent from repository -->
10
10
</parent >
11
11
<groupId >org.neo4j.tips.sdn</groupId >
27
27
<groupId >org.springframework.boot</groupId >
28
28
<artifactId >spring-boot-starter-data-rest</artifactId >
29
29
</dependency >
30
+ <dependency >
31
+ <groupId >org.springframework.data</groupId >
32
+ <artifactId >spring-data-neo4j</artifactId >
33
+ <version >6.3.0-SNAPSHOT</version >
34
+ </dependency >
30
35
<dependency >
31
36
<groupId >eu.michael-simons.neo4j</groupId >
32
37
<artifactId >neo4j-migrations-spring-boot-starter</artifactId >
69
74
</plugin >
70
75
</plugins >
71
76
</build >
77
+ <repositories >
78
+ <repository >
79
+ <id >spring-milestones</id >
80
+ <name >Spring Milestones</name >
81
+ <url >https://repo.spring.io/milestone</url >
82
+ <snapshots >
83
+ <enabled >false</enabled >
84
+ </snapshots >
85
+ </repository >
86
+ </repositories >
87
+ <pluginRepositories >
88
+ <pluginRepository >
89
+ <id >spring-milestones</id >
90
+ <name >Spring Milestones</name >
91
+ <url >https://repo.spring.io/milestone</url >
92
+ <snapshots >
93
+ <enabled >false</enabled >
94
+ </snapshots >
95
+ </pluginRepository >
96
+ </pluginRepositories >
72
97
73
98
</project >
Original file line number Diff line number Diff line change 1
1
package org .neo4j .tips .sdn .sdn6_rest ;
2
2
3
- import org .neo4j .tips .sdn .sdn6_rest .movies .Actor ;
4
3
import org .neo4j .tips .sdn .sdn6_rest .movies .Movie ;
5
- import org .neo4j .tips .sdn .sdn6_rest .movies .Person ;
6
4
import org .springframework .context .annotation .Bean ;
7
5
import org .springframework .context .annotation .Configuration ;
8
6
import org .springframework .data .rest .core .config .RepositoryRestConfiguration ;
9
7
import org .springframework .data .rest .webmvc .config .RepositoryRestConfigurer ;
10
- import org .springframework .hateoas .EntityModel ;
11
- import org .springframework .hateoas .server .EntityLinks ;
12
- import org .springframework .hateoas .server .RepresentationModelProcessor ;
13
8
import org .springframework .web .servlet .config .annotation .CorsRegistry ;
14
9
15
10
@ Configuration (proxyBeanMethods = false )
@@ -25,17 +20,4 @@ public void configureRepositoryRestConfiguration(RepositoryRestConfiguration con
25
20
26
21
};
27
22
}
28
-
29
- @ Bean
30
- RepresentationModelProcessor <EntityModel <Actor >> actorResourceProcessor (final EntityLinks entityLinks ) {
31
- // Don't use a lambda here, otherwise the type will evaporate (some Spring thing I really don't wanna debug right now)
32
- return new RepresentationModelProcessor <EntityModel <Actor >>() {
33
- @ Override public EntityModel <Actor > process (EntityModel <Actor > model ) {
34
- if (model .getContent ().getPerson () != null ) {
35
- model .add (entityLinks .linkToItemResource (Person .class , model .getContent ().getPerson ().getId ()));
36
- }
37
- return model ;
38
- }
39
- };
40
- }
41
23
}
Original file line number Diff line number Diff line change @@ -19,7 +19,8 @@ public final class Actor {
19
19
private Long id ;
20
20
21
21
@ TargetNode
22
- @ JsonIgnore
22
+ @ JsonUnwrapped
23
+ @ JsonIgnoreProperties ({ "id" })
23
24
private final Person person ;
24
25
25
26
private final List <String > roles ;
@@ -37,5 +38,3 @@ public List<String> getRoles() {
37
38
return List .copyOf (roles );
38
39
}
39
40
}
40
-
41
-
Original file line number Diff line number Diff line change
1
+ package org .neo4j .tips .sdn .sdn6_rest .movies ;
2
+
3
+ import org .springframework .data .rest .core .config .Projection ;
4
+
5
+ @ Projection (name = "inlineName" , types = { Person .class })
6
+ public interface InlineName {
7
+
8
+ String getName ();
9
+ }
Original file line number Diff line number Diff line change 6
6
import org .springframework .data .neo4j .repository .Neo4jRepository ;
7
7
import org .springframework .data .neo4j .repository .query .Query ;
8
8
import org .springframework .data .rest .core .annotation .RepositoryRestResource ;
9
- import org .springframework .data .rest .core .annotation .RestResource ;
10
9
11
10
/**
12
11
* @author Michael J. Simons
13
12
*/
14
- @ RepositoryRestResource (path = "people" )
13
+ @ RepositoryRestResource (path = "people" , excerptProjection = InlineName . class )
15
14
public interface PeopleRepository extends Neo4jRepository <Person , UUID > {
16
15
17
16
@ Query ("""
Original file line number Diff line number Diff line change 3
3
import java .util .UUID ;
4
4
5
5
import org .springframework .data .annotation .PersistenceConstructor ;
6
+ import org .springframework .data .annotation .PersistenceCreator ;
6
7
import org .springframework .data .neo4j .core .schema .GeneratedValue ;
7
8
import org .springframework .data .neo4j .core .schema .Id ;
8
9
import org .springframework .data .neo4j .core .schema .Node ;
@@ -19,7 +20,7 @@ public final class Person {
19
20
20
21
private Integer born ;
21
22
22
- @ PersistenceConstructor
23
+ @ PersistenceCreator
23
24
private Person (UUID id , String name , Integer born ) {
24
25
this .id = id ;
25
26
this .born = born ;
You can’t perform that action at this time.
0 commit comments