我是neo4j的新手,使用可用的示例项目SDN4 university" https://github.com/neo4j-examples/movies-java-spring-data-neo4j-4"进行理解。在同一个项目中添加了名为' Link'的新节点。也与电影节点有关系。添加额外的节点和与电影的关系后得到以下错误:
测试运行:2,失败:0,错误:2,跳过:0,经过时间:4.502秒<<<失败! - 在movie.repositories.MovieRepositoryTest中 testFindByTitle(movie.repositories.MovieRepositoryTest)经过的时间:0.36秒<<<错误! org.springframework.dao.InvalidDataAccessApiUsageException:将GraphModel映射到movie.domain.Movie实例时出错;嵌套异常是org.neo4j .ogm.exception.MappingException:将GraphModel映射到movie.domain.Movie实例时出错 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
@NodeEntity
public class Movie{
@Relationship(type = "ACTED_IN", direction = Relationship.INCOMING)
private List<Role> roles = new ArrayList<>();
@Relationship(type = "MOVIE_LINK", direction = Relationship.INCOMING)
private List<Link> links = new ArrayList<>();
}
@NodeEntity
public class Link{
@Relationship(type = "MOVIE_LINK")
private Movie movie = new Movie();
}
@RelationshipEntity(type = "MOVIE_LINK")
public class MovieLink
{
public MovieLink(Movie movie, Link link){
super();
this.movie = movie;
this.link = link;
}
答案 0 :(得分:1)
节点和关系实体的类必须具有无参数的公共构造函数,因此OGM可以实例化实体。