@Relationship映射无法正常工作,给出了空值

时间:2019-01-21 12:46:52

标签: neo4j spring-data-neo4j neo4j-ogm

在执行密码查询后,Neo4j-OGM没有正确映射“关系”字段(标记为@Relationship)。这是实体定义:

@NodeEntity(label = "Table")
public class NTable {
    @Id
    @GeneratedValue
    private Long id;
    private String db;
    private String name;
    private Integer latestVersion;

    @Relationship(type = "TD", direction = Relationship.INCOMING)
    private List<NTable> srcTables;

    public NTable() {
    }

    public NTable(String db, String name, Integer latestVersion) {
        this.db = db;
        this.name = name;
        this.latestVersion = latestVersion;
    }

    // getters and setters

}

@RelationshipEntity(type = "TD")
public class RTableDownstream {
    @Id
    @GeneratedValue
    private Long id;

    private Integer version;
    private Long createTime;
    private Long lastModifiedTime;

    @StartNode
    private NTable srcTable;

    @EndNode
    private NTable destTable;


    public RTableDownstream() {
    }

    public RTableDownstream(NTable srcTable, NTable destTable) {
        this.srcTable = srcTable;
        this.destTable = destTable;
    }

    // getters and setters

存储库定义如下:

@Repository
public interface LineageRepository extends Neo4jRepository<NTable, Long> {

    @Query("match (t:Table {db: {db}, name: {name}})<-[td:TD]-(t2:Table) return t,td,t2")
    Collection<NTable> getTable(@Param("db") String db,
                    @Param("name") String name);
}

执行代码后,srcTables字段为空。带有以下测试图:

merge (t1:Table {db:'tmp', name:'T1', latestVersion: 1})
merge (t2:Table {db:'tmp', name:'T2', latestVersion: 1})
merge (t1)-[tw:TD]->(t2)

spring-boot-starter-data-neo4j的版本:1.5.7.RELEASE neo4j的版本:3.5.1

有什么想法吗?谢谢。

0 个答案:

没有答案