我通过以下方式配置它们,但它无法创建数据。
https://spring.io/guides/gs/accessing-neo4j-data-rest/
就像:
# curl -i -X POST -H "Content-Type:application/json" -d '{ "name" : "testAsset", "os" : "test", "id":1000000}' http://192.168.10.42:8080/Asset
并且响应代码201,没有任何异常或错误,但我从来没有能够查询刚刚插入的数据。
我有没有打开它的开关?
这是我的存储库:
@RepositoryRestResource(collectionResourceRel = "Asset", path = "Asset")
public interface AssetRepository extends PagingAndSortingRepository<Asset, Long> {
@Query("Match(node:" + GlobalInfo.NODE_ASSET + ") where node.name = {name} return node limit 1")
Asset isExist(@Param("name") String name);
}
实体:
@NodeEntity(label = "Asset")
public class Asset {
@Id @GeneratedValue private long id ;
private String name;
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;
}
}
--------- ----------更新
EntityGraphMapper.class
if (id < 0) {
nodeBuilder = compiler.newNode(id).addLabels(labels).setPrimaryIndex(primaryIndex);
context.registerNewObject(id, entity);
} else {
nodeBuilder = compiler.existingNode(Long.valueOf(id.toString()));
nodeBuilder.addLabels(labels).setPrimaryIndex(primaryIndex);
removePreviousLabelsIfRequired(entity, classInfo, nodeBuilder);
}
我的ID类型是“长”不是“长” 默认值为0且为null,