org.neo4j.ogm.exception.MappingException: Error mapping GraphModel to instance of ***.ProjectGraph

实例化知识图谱对象ProjectGraph.java 提示如下截图错误信息:

 Exception in thread "main" org.neo4j.ogm.exception.MappingException: Error mapping GraphModel to instance of .ProjectGraph
    at org.neo4j.ogm.context.GraphEntityMapper.mapEntities(GraphEntityMapper.java:145)
    at org.neo4j.ogm.context.GraphEntityMapper.map(GraphEntityMapper.java:117)
    at org.neo4j.ogm.context.GraphEntityMapper.map(GraphEntityMapper.java:81)
    at org.neo4j.ogm.session.delegates.ExecuteQueriesDelegate.executeAndMap(ExecuteQueriesDelegate.java:111)
    at org.neo4j.ogm.session.delegates.ExecuteQueriesDelegate.query(ExecuteQueriesDelegate.java:82)
    at org.neo4j.ogm.session.Neo4jSession.query(Neo4jSession.java:323)

Caused by: org.neo4j.ogm.exception.MappingException: Unable to instantiate class .ProjectGraph
    at org.neo4j.ogm.annotations.EntityFactory.instantiate(EntityFactory.java:137)
    at org.neo4j.ogm.annotations.EntityFactory.instantiateObjectFromTaxa(EntityFactory.java:110)
    at org.neo4j.ogm.annotations.EntityFactory.newObject(EntityFactory.java:61)
    at org.neo4j.ogm.context.GraphEntityMapper.mapNodes(GraphEntityMapper.java:156)
    at org.neo4j.ogm.context.GraphEntityMapper.mapEntities(GraphEntityMapper.java:142)
    ... 7 more
Caused by: java.lang.NoSuchMethodException: .ProjectGraph.()
    at java.lang.Class.getConstructor0(Class.java:3082)
    at java.lang.Class.getDeclaredConstructor(Class.java:2178)
    at org.neo4j.ogm.annotations.EntityFactory.instantiate(EntityFactory.java:133)
    ... 11 more

造成的原因:ProjectGraph.java 需要没有任何属性的构造函数,补全ProjectGraph 没有任何属性的构造函数。

ProjectGraph.java 错误代码:


import java.util.List;

import org.neo4j.ogm.annotation.GraphId;
import org.neo4j.ogm.annotation.NodeEntity;
import org.neo4j.ogm.annotation.Relationship;

/**
 * 单位工程图谱对象
 * 
 *
 */
@NodeEntity
@SuppressWarnings("serial")
public class ProjectGraph implements java.io.Serializable{
	@GraphId
	private Long id;
	private String name;
	private String sid;
	
	@Relationship(type = "IndividualLicenseRelation")
	private List licenses;
	
	@Relationship(type = "IndividualResponRelation")
	private List respons;
	
	@Relationship(type = "IndividualUnitRelation")
	private List units;
	
	//set 和 get 方法
	public Long getId() {
		return id;
	}
	public void setId(Long id) {
		this.id = id;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getSid() {
		return sid;
	}
	public void setSid(String sid) {
		this.sid = sid;
	}

	public List getLicenses() {
		return licenses;
	}
	public void setLicenses(List licenses) {
		this.licenses = licenses;
	}
	public List getRespons() {
		return respons;
	}
	public void setRespons(List respons) {
		this.respons = respons;
	}
	public List getUnits() {
		return units;
	}
	public void setUnits(List units) {
		this.units = units;
	}
	
	public ProjectGraph(String name, String sid) {
		this.name = name;
		this.sid = sid;
	}
	
}

ProjectGraph.java 修正后的代码:


import java.util.List;

import org.neo4j.ogm.annotation.GraphId;
import org.neo4j.ogm.annotation.NodeEntity;
import org.neo4j.ogm.annotation.Relationship;

/**
 * 单位工程图谱对象
 * 
 *
 */
@NodeEntity
@SuppressWarnings("serial")
public class ProjectGraph implements java.io.Serializable{
	@GraphId
	private Long id;
	private String name;
	private String sid;
	
	@Relationship(type = "IndividualLicenseRelation")
	private List licenses;
	
	@Relationship(type = "IndividualResponRelation")
	private List respons;
	
	@Relationship(type = "IndividualUnitRelation")
	private List units;
	
	//set 和 get 方法
	public Long getId() {
		return id;
	}
	public void setId(Long id) {
		this.id = id;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getSid() {
		return sid;
	}
	public void setSid(String sid) {
		this.sid = sid;
	}

	public List getLicenses() {
		return licenses;
	}
	public void setLicenses(List licenses) {
		this.licenses = licenses;
	}
	public List getRespons() {
		return respons;
	}
	public void setRespons(List respons) {
		this.respons = respons;
	}
	public List getUnits() {
		return units;
	}
	public void setUnits(List units) {
		this.units = units;
	}
	// 构造函数
	public ProjectGraph() {
		super();
	}

	public ProjectGraph(String name, String sid) {
		this.name = name;
		this.sid = sid;
	}
	
}

 

你可能感兴趣的:(neo4j)