Your challenge is to use the skills from last lesson to create a class for the Person domain.
Person node properties
In the src/main/java/com/example/appspringdata
directory, create a new file called Person.java
, then choose class
as the type. Utilizing the following list of properties and data types for the Person node in Neo4j, map your domain class with the imdbId
field as the class’s identifier and an @Node
annotation at the top. You can also verify the data types yourself by running the query shown in the sandbox tab on the right.
{
born:"DATE",
bornIn:"STRING",
tmdbId:"STRING",
bio:"STRING",
died:"DATE",
name:"STRING",
poster:"STRING",
imdbId:"STRING",
url:"STRING"
}
Reference the Cypher-to-Java data type mappings from the documentation, if needed.
Click to reveal the completed Person
domain class code
import org.springframework.data.neo4j.core.schema.Id;
import org.springframework.data.neo4j.core.schema.Node;
import java.time.LocalDate;
@Node
public class Person {
@Id
private String imdbId;
private String tmdbId;
private String name;
private String bio;
private String poster;
private String url;
private String bornIn;
private LocalDate born;
private LocalDate died;
public Person(String imdbId, String tmdbId, String name, String bio, String poster, String url, String bornIn,
LocalDate born, LocalDate died) {
this.imdbId = imdbId;
this.tmdbId = tmdbId;
this.name = name;
this.bio = bio;
this.poster = poster;
this.url = url;
this.bornIn = bornIn;
this.born = born;
this.died = died;
}
public String getImdbId() {
return imdbId;
}
public void setImdbId(String imdbId) {
this.imdbId = imdbId;
}
public String getTmdbId() {
return tmdbId;
}
public void setTmdbId(String tmdbId) {
this.tmdbId = tmdbId;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getBio() {
return bio;
}
public void setBio(String bio) {
this.bio = bio;
}
public String getPoster() {
return poster;
}
public void setPoster(String poster) {
this.poster = poster;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public String getBornIn() {
return bornIn;
}
public void setBornIn(String bornIn) {
this.bornIn = bornIn;
}
public LocalDate getBorn() {
return born;
}
public void setBorn(LocalDate born) {
this.born = born;
}
public LocalDate getDied() {
return died;
}
public void setDied(LocalDate died) {
this.died = died;
}
}
Lesson Summary
In this challenge, you used what you have learned to create the domain class for Person entities.
In the next lesson, you will learn how to create the interface and controller class to access the Movie
domain entities.