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

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

问题描述

我使用的是 JPA 2.0.(EclipseLink 2.0.2)

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;

我在通过 RPC 发送时收到以下错误:

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 = {[]}

推荐答案

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

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天全站免登陆