Spring Data Neo4j Repository Save 方法正在执行 UNWIND MATCH 而不是 UNWIND CREATE
Spring Data Neo4j Repository Save method is doing UNWIND MATCH instread of UNWIND CREATE
spring data neo4j rest example
请在下面找到类
型号Class
@Data
@NodeEntity
public class Model implements Serializable {
@Id
@GeneratedValue
private Long id;
private String name;
private String uUID;
private boolean status = true;
@CreatedDate
private Date createdDate;
@LastModifiedDate
private Date modifiedDate;
}
模型库Class
@Repository
public interface ModelRepository extends Neo4jRepository<Model, Long> {
Optional<Model> findByStatusTrueAndUUID(UUID uuid);
Stream<Model> streamAllByStatusTrue();
}
服务Class方法
public Model createModel(Model request) throws DSException {
return modelRepository.save(request);
}
Repository.save 方法生成了以下密码查询
UNWIND {rows} as row MATCH (n) WHERE ID(n)=row.nodeId SET n:`Model` SET n += row.props RETURN row.nodeId as ref, ID(n) as id, {type} as type with params {type=node, rows=[{nodeId=1, props={createdDate=null, name=1-name, modifiedDate=2019-02-26T12:05:16.184Z, uUID=05fdb066-13a4-4ed2-b53f-f3e48b5ff9ba, status=true}}]}
由于上面的密码查询有 MATCH
而不是 CREATE
,请求节点不会持久存在于 neo4j 数据库中
请帮助理解和解决问题。
以下是使用的版本:
spring-data-neo4j:5.0.7.RELEASE
问题出在添加的 属性 类型上。如果您不传递正确的 属性 类型,如 @NodeEntity
提供的字符串或整数,我们会遇到此错误
我遇到了同样的问题。
最后我发现如果你为模型分配了 id 属性 Neo4j Repository Save 方法正在执行 UNWIND MATCH 而不是 UNWIND CREATE;
如果您没有分配 id,那么 Neo4j Repository Save 方法正在执行 UNWIND CREATE。
spring data neo4j rest example
请在下面找到类型号Class
@Data
@NodeEntity
public class Model implements Serializable {
@Id
@GeneratedValue
private Long id;
private String name;
private String uUID;
private boolean status = true;
@CreatedDate
private Date createdDate;
@LastModifiedDate
private Date modifiedDate;
}
模型库Class
@Repository
public interface ModelRepository extends Neo4jRepository<Model, Long> {
Optional<Model> findByStatusTrueAndUUID(UUID uuid);
Stream<Model> streamAllByStatusTrue();
}
服务Class方法
public Model createModel(Model request) throws DSException {
return modelRepository.save(request);
}
Repository.save 方法生成了以下密码查询
UNWIND {rows} as row MATCH (n) WHERE ID(n)=row.nodeId SET n:`Model` SET n += row.props RETURN row.nodeId as ref, ID(n) as id, {type} as type with params {type=node, rows=[{nodeId=1, props={createdDate=null, name=1-name, modifiedDate=2019-02-26T12:05:16.184Z, uUID=05fdb066-13a4-4ed2-b53f-f3e48b5ff9ba, status=true}}]}
由于上面的密码查询有 MATCH
而不是 CREATE
,请求节点不会持久存在于 neo4j 数据库中
请帮助理解和解决问题。 以下是使用的版本:
spring-data-neo4j:5.0.7.RELEASE
问题出在添加的 属性 类型上。如果您不传递正确的 属性 类型,如 @NodeEntity
提供的字符串或整数,我们会遇到此错误
我遇到了同样的问题。 最后我发现如果你为模型分配了 id 属性 Neo4j Repository Save 方法正在执行 UNWIND MATCH 而不是 UNWIND CREATE; 如果您没有分配 id,那么 Neo4j Repository Save 方法正在执行 UNWIND CREATE。