Reputation: 27
Does anyone already have the same issue when arangtoDB edge collection was linking to different objects? and was able to use ArangoSpring driver to operate with this without any problem?
I have this edge
@Data
@Edge("link2User")
public class Link2User<T> {
@Id
private String key;
@From
private User user;
@To
private T to;
@Getter @Setter private String data;
...
public Link2User(final User user, final T to) {
super();
this.user = user;
this.to = to;
...
}
than repository
@Component
public interface Link2UserRepository<T> extends ArangoRepository<Link2User<T>, String> {
}
and when I try call:
@Autowired
Link2UserRepository<Item> l2uRepository;
...
Link2User<Item> link1 = new Link2User<Item>( user, Item);
v2uRepository.save(link1 );
My link is stored into ArangoDB but I get error:
DOP. org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.data.mapping.MappingException: Couldn't find PersistentEntity for type class java.lang.Object!] with root cause
org.springframework.data.mapping.MappingException: Couldn't find PersistentEntity for type class java.lang.Object!
Upvotes: 0
Views: 516
Reputation: 667
Due to type erasure, the library cannot detect at runtime the class of the generic field @To
, therefore it cannot find the related persistent entity.
You can work around it by creating a class:
public class Link2UserOfItem extends Link2User<Item> {
public Link2UserOfItem(final User user, final Item to) {
super(user,to);
}
}
And:
@Autowired
Link2UserRepository<Item> l2uRepository;
...
Link2User<Item> link1 = new Link2UserToItem( user, Item);
l2uRepository.save(link1 );
In this way Spring Data ArangoDB will save an additional type hint field ("_class": "<pkg>.Link2UserOfItem"
) and will use it on read to deserialize it.
Upvotes: 1