简体   繁体   中英

Is there an option to add different collection in edge using arangodb-spring-data

In arangoDB, we can create an edge in which we can set @from and @to to different collection since these are all json data. In ArangoDB-Spring-Data library we can create an edge and we have to provide type to @from and @to. I want to add relation between different collection using same edge. For example- I have a class EntitywithKey-

public class EntityWithKey {
     @Id
     protected String id;
}

I have 2 classes which extends 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;
}

i want to create an edge like below-

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

So that i can add relationship between Actor-Actor, Actor-Character, Character-Character and Character-Actor.

But i am seeing an error nested exception is org.springframework.data.mapping.PropertyReferenceException: No property name found for type EntityWithKey!

Is there any option with this library to do that?

I have fixed the issue. The edge will have to be created with java generics-

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

Now i can add any two connectors in single edge relationship

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM