简体   繁体   English

为什么此类无法序列化?

[英]Why this class not serializable?

I have error: 我有错误:

com.google.gwt.user.client.rpc.SerializationException: Type 'ru.xxx.empeditor.client.Dept$$EnhancerByCGLIB$$2f6af516' 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 = ru.xxx.empeditor.client.Dept@e53d4e

Why this class not serializable? 为什么此类无法序列化?

package ru.xxx.empeditor.client;

import java.util.HashSet;
import java.util.Set;

import com.google.gwt.user.client.rpc.IsSerializable;

/**
 * Dept generated by hbm2java
 */
public class Dept implements IsSerializable {

    private byte deptno;
    private String dname;
    private String loc;
    private Set<Emp> emps = new HashSet<Emp>(0);

    public Dept() {
    }

    public Dept(byte deptno) {
        this.deptno = deptno;
    }

    public Dept(byte deptno, String dname, String loc, Set<Emp> emps) {
        this.deptno = deptno;
        this.dname = dname;
        this.loc = loc;
        this.emps = emps;
    }

    public byte getDeptno() {
        return this.deptno;
    }

    public void setDeptno(byte deptno) {
        this.deptno = deptno;
    }

    public String getDname() {
        return this.dname;
    }

    public void setDname(String dname) {
        this.dname = dname;
    }

    public String getLoc() {
        return this.loc;
    }

    public void setLoc(String loc) {
        this.loc = loc;
    }

    public Set<Emp> getEmps() {
        return this.emps;
    }

    public void setEmps(Set<Emp> emps) {
        this.emps = emps;
    }

}

Check if the class Emp is serialiable. 检查Emp类是否可序列化。

Another potential issue (since you are using Hibernate - noticed the auto-generated comment) could be because of Proxies that modify your bean's byte code, as a result of which GWT fails to serialize it. 另一个潜在的问题(因为您正在使用Hibernate-注意到自动生成的注释)可能是由于代理修改了您的bean的字节码,导致GWT无法序列化它。 As mentioned here - http://code.google.com/webtoolkit/articles/using_gwt_with_hibernate.html 如此处所述-http: //code.google.com/webtoolkit/articles/using_gwt_with_hibernate.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM