spring 数据 neo4j 6 @Query 传递列表参数在从 List<Pojo> 转换为类型 [org.neo4j.driver.Value] 时抛出 ConverterNotFoundException

spring data neo4j 6 @Query passing list param throws ConverterNotFoundException on converting from List<Pojo> to type [org.neo4j.driver.Value]

我尝试使用带有 @Query 的自定义查询来更新关系属性,其中它与 java 对象一起使用,但不与 collection / List 一起使用,如下所示:

@Query("UNWIND $relations \n" +
        "AS item \n" +
        "MATCH (f:PERSON {nid: $from})-[r:KNOWS]->(t:LANGUAGE {name: $to}) \n" +
        "WHERE ID(r) = item.id SET r.description = item.description \n" +
        "return f, collect(r), collect(t)")
ResponseType updateRelation(@Param("from") String from, @Param("to") String to, @Param("relations") List<KnowsEntity> relEntites);

当我调用此方法时,它会抛出如下错误:

org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from type [*.KnowsEntity] to type [org.neo4j.driver.Value]

这是否意味着我需要自定义转换器才能完成这项工作?

此外,当我像在 Neo4j 浏览器中那样硬编码 json 结构时,它工作正常。

注意:with subject to keys 不能用引号引起来!

@Query("UNWIND [{description:\"defining value\",id:0},{description:\"blah blah\",id:3}] \n" +
        "AS item \n" +
        "MATCH (f:PERSON {nid: $from})-[r:KNOWS]->(t:LANGUAGE {name: $to}) \n" +
        "WHERE ID(r) = item.id SET r.description = item.description \n" +
        "return f, collect(r), collect(t)")
ResponseType updateRelation(@Param("from") String from, @Param("to") String to);

请纠正我是否遗漏了什么/使用对象列表进行更新的更好方法。

感谢您提出这个问题,我认为这只是一个缺失的功能:https://github.com/spring-projects/spring-data-neo4j/issues/2292

修复link is working in locally build inputs. Thanks

但是,如果输入是通过 http 有效负载,那么我们需要更改 @RequestBody 的实体级别以进行序列化并通过 SDN。

@RelationshipProperties
@Data
public class KnowsEntity {

    @JsonView(Views.Public.class) // it might not be needed
    @Id
    @GeneratedValue
    private Long id;

    @JsonView(Views.Public.class)
    @Property
    private Boolean read;

    @JsonView(Views.Public.class)
    @Property
    private Boolean write;

    @JsonView(Views.Public.class)
    @TargetNode
    private Language language;

}

@Node(primaryLabel = "LANGUAGE")
public class Language {

    @JsonView(Views.Public.class)
    @Id
    private String name;

}

public class Views {
    public static class Public {
    }
}

并在控制器中获取参数为

@RequestBody @JsonView(Views.Public.class) Set<KnowsEntity> knows