Challenge: Create Person class

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.

text
{
  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
java
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 String getTmdbId() {
        return tmdbId;
    }

    public String getName() {
        return name;
    }

    public String getBio() {
        return bio;
    }

    public String getPoster() {
        return poster;
    }

    public String getUrl() {
        return url;
    }

    public String getBornIn() {
        return bornIn;
    }

    public LocalDate getBorn() {
        return born;
    }

    public LocalDate getDied() {
        return 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.