Spring Data Neo4j中的DynamicRelationshipType或在运行时定义关系类型 [英] DynamicRelationshipType in Spring Data Neo4j or defining relationship types at runtime

查看:202
本文介绍了Spring Data Neo4j中的DynamicRelationshipType或在运行时定义关系类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以在运行时指定关系类型吗?

Can I specify relationship type at runtime??

我正在使用

@Fetch
@RelatedToVia(type="RELATED_IN_SOME_WAY", direction = Direction.BOTH)
Set<ThingRelationship> relationships = new HashSet<ThingRelationship>();

ThingRelationship是

where ThingRelationship is

@RelationshipEntity
public class ThingRelationship {

public ThingRelationship() {
    super();
}

//incremental neo4j set ID
@GraphId Long nodeId;

//Start and end nodes
@StartNode Thing startThing;
@EndNode Thing endThing;

//Relationship Type
@org.springframework.data.neo4j.annotation.RelationshipType
String relationship;

但是我不想在编译时而是在运行时指定关系类型( type ="RELATED_IN_SOME_WAY" ).当我删除type ="RELATED_IN_SOME_WAY时,出现错误,必须定义默认类型

However I DONT want to specify the relationship type (type="RELATED_IN_SOME_WAY") at compile time but rather at runtime. When I remove type="RELATED_IN_SOME_WAY I get an error that a default type must be defined

在Neo4j中,我认为这样的运行时关系类型需要使用 DynamicRelationshipType ,但是我不认为Spring Data Neo4j支持此概念.

In Neo4j such a runtime relationship type I think requires the use of DynamicRelationshipType however I dont think the Spring Data Neo4j supports this concept.

我可以纠正吗,如果可以,这个问题有解决办法吗?我是否需要转储Spring Data Neo4j并转而使用Core API?

Am I correct and if so is there anyway around this problem? Do I need to dump Spring Data Neo4j and go to use the Core API instead?

推荐答案

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆