【问题标题】:Is there an option to add different collection in edge using arangodb-spring-data是否可以选择使用 arangodb-spring-data 在边缘添加不同的集合
【发布时间】:2020-06-10 21:27:17
【问题描述】:

在 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】:

    我已经解决了这个问题。必须使用 java 泛型创建边缘-

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

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

    【讨论】:

      猜你喜欢
      • 2020-12-27
      • 1970-01-01
      • 1970-01-01
      • 2020-08-01
      • 2016-05-15
      • 1970-01-01
      • 2020-03-23
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多