0
這是我的pom.xml:爲什麼Neo4jTemplate覆蓋節點號碼而不是內容?
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-neo4j</artifactId>
<version>3.2.0.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-neo4j-rest</artifactId>
<version>3.2.1.RELEASE</version>
</dependency>
和config.xml中
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:neo4j="http://www.springframework.org/schema/data/neo4j"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation=" http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/data/neo4j
http://www.springframework.org/schema/data/neo4j/spring-neo4j.xsd">
<!-- REST Connection to Neo4j server -->
<bean id="graphDatabaseService"
class="org.springframework.data.neo4j.rest.SpringRestGraphDatabase">
<constructor-arg index="0" value="http://localhost:7474/db/data" />
</bean>
<!-- graphDatabaseService- Neo4j configuration (creates Neo4jTemplate) -->
<neo4j:config
storeDirectory="db/neo4j/data/graph.db"
base-package="x.y.z.mediator.domain.model"
graphDatabaseService="graphDatabaseService"/>
</beans>
我想自動裝配的neo4jtemplate形式Neo4j的獨立服務器:
@Repository
public class EmployeeDAO_Neo4j implements EmployeeDAO {
@Inject
private Neo4jTemplate neo4jTemplate;
@Override
public List<Map<String, Object>> findAll(String query) {
//Object is the node address
Result<Map<String, Object>> result = neo4jTemplate.query("MATCH (emp:`EmpBase`) RETURN emp;", null);
//Below line results with: {emp=http://localhost:7474/db/data/node/1}
System.out.println("Results:"+ result.as(List.class).get(1).toString());
List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
Map<String, Object> map = null;
for(EmployeeBase u : result.to(EmployeeBase.class)) {
map = new HashMap<String, Object>();
map.put(u.getE_id().toString(), u.toString());
list.add(map);
}
System.out.println(result.to(EmployeeBase.class).as(List.class).get(1));
return list;
}
}
返回列表是4元素之一,但它說每System.out.println
從上面的代碼:{e_id=1, e_bossId=null, e_name='null'}
所以它是n加時賽填充,因爲測試數據是:
$ cat /tmp/empbase.csv
e_id,e_bossid,e_name
11,11,Smith
12,11,Johnson
13,11,Roberts
14,13,Doe
與結果行只給出:{emp=http://localhost:7474/db/data/node/1}
的數據Neo4j的服務器來自CSV導入。 empfull.csv:
CREATE empbase;
// Import data and schema for empbase; the '_EmpBase' is required by SpringData-neo4j
USING PERIODIC COMMIT 500
LOAD CSV WITH HEADERS FROM "file:/tmp/empbase.csv" AS row
CREATE (:EmpBase:_EmpBase { neo_eb_id: row.e_id,
neo_eb_bossID: row.e_bossid,
neo_eb_name: row.e_name});
//Create index
CREATE INDEX ON :EmpBase:(neo_eb_id);
// Create relationships
LOAD CSV WITH HEADERS FROM "file:/tmp/empbase.csv" AS row
MATCH (employee:EmpBase:_EmpBase {neo_eb_id: row.e_id})
MATCH (manager:EmpBase:_EmpBase {neo_eb_id: row.e_bossid})
MERGE (employee)-[:REPORTS_TO]->(manager);
它是SDN或某事的錯誤是不對的配置?
PS。 xml config中的db/neo4j/data/graph.db
永遠不會生成。我跑這個項目mvn clear package
PS2: 這是EmployeeBase.java
@NodeEntity
public class EmployeeBase {
@GraphId
private Long e_id;
private Integer e_bossId;
private String e_name;
public Long getE_id() {
return e_id;
}
public Integer getE_bossId() {
return e_bossId;
}
public String getE_name() {
return e_name;
}
@Override
public String toString() {
return "{" +
"e_id=" + e_id +
", e_bossId=" + e_bossId +
", e_name='" + e_name + '\'' +
'}';
}
}
**對於任何人誰可以搜索Neo4jTemplate空值解決方案:實體類必須具有相同的字段名稱作爲節點屬性名稱** – Szczepan 2014-11-08 18:49:58