Database Reference
In-Depth Information
3. Now, let's annotate this class with @NodeEntity . This is to indicate and inform
the Spring framework that this POJO ( Artist.java ) is an entity of a node,
which will be persisted in the Neo4j database.
4. Next annotate the property graphId with @GraphId . This is to indicate that
this field will be used to store the unique node IDs generated by Neo4j.
5. There is another property, id , which we have created to store a user-generated
unique ID. This is to make sure that we do not depend upon GraphId for
uniqueness of our nodes. Let's define a unique index on the id property by annot-
ating it with @Indexed(unique=true) . This is similar to creating a unique
index on a node property in the Neo4j database.
The rest of the attributes, that is, name and year_Of_Birth , would be used to
store the name of the artist and his year of birth. The updated Artist.java
class would look like this:
package org.neo4j.spring.samples.domain;
import org.springframework.data.neo4j.annotation.*;
@NodeEntity
public class Artist {
@GraphId
private Long graphId;
@Indexed ( unique=true )
private String id;
private String [] workedAs;
private String name;
private int year_Of_Birth;
//Define getters and setters for all properties.
}
6. Next, create a org.neo4j.spring.samples.domain.Movie.java
class and define the following properties and annotation:
package org.neo4j.spring.samples.domain;
Search WWH ::




Custom Search