通过GWT RPC问题与关系的实体 [英] entity with relationships through GWT RPC problem

查看:123
本文介绍了通过GWT RPC问题与关系的实体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用JPA 2.0。 (EclipseLink 2.0.2)

如果实体包含关系,例如:

  @OneToMany(cascade = CascadeType.ALL,mappedBy =userId)
私人收藏< Blog> blogCollection;

当我通过RPC发送时,出现以下错误:

  com.google.gwt.user.client.rpc.SerializationException:类型'org.eclipse.persistence.indirection.IndirectList'未包含在无法加载可由此SerializationPolicy或其Class对象序列化的类型。为了安全起见,这种类型不会被序列化:实例= {[]} 


解决方案一般来说,所有的Persistence API都使用了一种名为代码注入的技术,这意味着它将注入POJO类中的代码以执行持久性作业。
因为这是在运行时执行的,所以GWT编译器无法看到,因此它不能为这些类型生成序列化程序。
解决方案不是通过电线发送持久性类。而是使用DTO(数据传输对象)。



希望这有助于您。
问候
Daniel


I am using JPA 2.0. (EclipseLink 2.0.2)

If an entity contains relations, for example:

@OneToMany(cascade = CascadeType.ALL, mappedBy = "userId")
private Collection<Blog> blogCollection;

I am getting the following error when I am sending it through RPC:

com.google.gwt.user.client.rpc.SerializationException: Type 'org.eclipse.persistence.indirection.IndirectList' was not included in the set of types which can be serialized by this SerializationPolicy or its Class object could not be loaded. For security purposes, this type will not be serialized.: instance = {[]}

解决方案

In general all the Persistence APIs use a technique named code injection, which means that it injects code in your POJOs classes in order to do persistence job. Because this is doing at runtime the GWT compiler was unable to see that, so it can't generates serializers for that types. The solutions is not to send Persistance Classes thru the wire. Instead use DTO (Data Transfer Objects).

Hope this helps. Regards Daniel

这篇关于通过GWT RPC问题与关系的实体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆