Spring Data Neo4j Repository Save方法正在进行UNWIND MATCH而不是UNWIND CREATE

问题描述 投票:0回答:1

请找到以下类别的spring数据neo4j rest示例

模型类

@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;

}

ModelRepository类

@Repository
public interface ModelRepository extends Neo4jRepository<Model, Long> {

   Optional<Model> findByStatusTrueAndUUID(UUID uuid);

   Stream<Model> streamAllByStatusTrue();
}

服务类方法

public Model createModel(Model request) throws DSException {
      return modelRepository.save(request);
}

Repository.save方法生成了以下cypher查询

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}}]}

由于上面的cypher查询有MATCH而不是CREATE,请求节点不会持久存在neo4j数据库中

请帮助理解和解决问题。以下是使用的版本:

spring-data-neo4j:5.0.7.RELEASE
neo4j spring-data-neo4j
1个回答
0
投票

问题在于添加的属性类型。如果你不传递@NodeEntity提供的正确的属性类型,如字符串或整数,我们会遇到此错误

© www.soinside.com 2019 - 2024. All rights reserved.