I would like to define some relationship type between some typed node. When I look example always they use a String to define relationship type, as in this example . By using:
我想在某个类型节点之间定义一些关系类型。当我查看示例时,他们总是使用String来定义关系类型,如本例所示。通过使用:
@RelationshipEntity(type = "ACTED_IN")
I tried to use org.neo4j.graphdb.RelationshipType but RelationshipEntity.type expect a string.
我试图使用org.neo4j.graphdb.RelationshipType但是RelationshipEntity.type期望一个字符串。
public enum PersonMovieRelationshipType implements RelationshipType {
ACTED_IN("ACTED_IN"),
AUTHOR("AUTHOR");
private String type;
PersonMovieRelationshipType( String type ){
this.type = type;
}
public String getType() {
return type;
}
}
RelationshipType enum provide a method "name()" what to do with ?
RelationshipType枚举提供了一个方法“name()”如何处理?
I do not like free text way, is it possible use an enum ?
我不喜欢*文本方式,是否可以使用枚举?
Any full example will be appreciated.
任何完整的例子将不胜感激。
Regards
问候
1 个解决方案
#1
5
You can't due to the way annotations work. What you could do is declaring the relation names as constants.
你不能因为注释的工作方式。你可以做的是将关系名称声明为常量。
interface RelationNames{
String ACTED_IN = "ACTED_IN";
}
And then use those constants in your code
然后在代码中使用这些常量
@RelationshipEntity(type = RelationNames.ACTED_IN)
#1
5
You can't due to the way annotations work. What you could do is declaring the relation names as constants.
你不能因为注释的工作方式。你可以做的是将关系名称声明为常量。
interface RelationNames{
String ACTED_IN = "ACTED_IN";
}
And then use those constants in your code
然后在代码中使用这些常量
@RelationshipEntity(type = RelationNames.ACTED_IN)