【问题标题】:entity with relationships through GWT RPC problem通过 GWT RPC 问题具有关系的实体
【发布时间】:2011-06-19 22:30:55
【问题描述】:

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

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

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

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

【问题讨论】:

    标签: gwt jpa-2.0 gwt-rpc


    【解决方案1】:

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

    希望这会有所帮助。 问候 丹尼尔

    【讨论】:

      【解决方案2】:

      此错误消息很可能意味着您的“博客”对象未实现 java.util.Serializablecom.google.gwt.user.client.rpc.IsSerializable

      RPC and Serializable Discussion

      【讨论】:

        猜你喜欢
        • 2021-03-08
        • 1970-01-01
        • 1970-01-01
        • 2014-09-27
        • 2010-10-31
        • 2011-10-01
        • 1970-01-01
        • 1970-01-01
        • 2010-11-06
        相关资源
        最近更新 更多