当arangtoDB边缘集合链接到不同的对象时,是否有人已经有同样的问题?并且能够使用ArangoSpring驱动程序进行操作而没有任何问题?
有这条边
@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;
...
}
比库
@Component
public interface Link2UserRepository<T> extends ArangoRepository<Link2User<T>, String> {
}
和当我尝试呼叫:
@Autowired
Link2UserRepository<Item> l2uRepository;
...
Link2User<Item> link1 = new Link2User<Item>( user, Item);
v2uRepository.save(link1 );
我的链接存储到ArangoDB,但我得到错误:
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!
由于类型擦除,库无法在运行时检测到泛型字段@To
的类,因此无法找到相关的持久实体。
public class Link2UserOfItem extends Link2User<Item> {
public Link2UserOfItem(final User user, final Item to) {
super(user,to);
}
}
:
@Autowired
Link2UserRepository<Item> l2uRepository;
...
Link2User<Item> link1 = new Link2UserToItem( user, Item);
l2uRepository.save(link1 );
通过这种方式,Spring Data ArangoDB将保存一个额外的类型提示字段("_class": "<pkg>.Link2UserOfItem"
),并在读取时使用它来反序列化它。