是否可以选择使用arangodb-spring-data在边缘添加其他集合

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

在arangoDB中,我们可以创建一个边,在其中可以将@from和@to设置为不同的集合,因为这些都是json数据。在ArangoDB-Spring-Data库中,我们可以创建一个边,并且必须将类型提供给@from和@to。我想在使用相同边缘的不同集合之间添加关系。例如-我有一个EntitywithKey-

public class EntityWithKey {
     @Id
     protected String id;
}

我有2个扩展EntityWIthKey的类

@Document("actors")
@HashIndex(fields = { "name", "surname" }, unique = true)
public class Actor extends EntityWithKey{
     private String name;
     private String surname;
}

@Document("characters")
@HashIndex(fields = { "name", "surname" }, unique = true)
public class Character extends EntityWithKey {
     private String name;
     private String surname;
}

我想创建下面的边-

@Edge
public class ChildOf {
     @Id
     private String id;
     @From
     private EntityWithKey child;
     @To
     private EntityWithKey parent;
}

以便我可以添加Actor-Actor,Actor-Character,Character-Character和Character-Actor之间的关系。

但是我看到一个错误nested exception is org.springframework.data.mapping.PropertyReferenceException: No property name found for type EntityWithKey!

此库是否有这样做的选项?

spring-boot arangodb arangodb-java
1个回答
0
投票

我已解决此问题。必须使用Java泛型创建边缘-

@Edge
public class ChildOf<T1,T2> {
     @Id
     private String id;
     @From
     private T1 child;
     @To
     private T2 parent;
}

现在我可以以单边关系添加任何两个连接器

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