GWT JPA - 响应无法反序列化 [英] GWT JPA - The response could not be deserialized

查看:300
本文介绍了GWT JPA - 响应无法反序列化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用GWT和JPA进行持久化。我创建了一个域JPA附魔类,DAO和RPC用于它们之间的通信。一切正常,通过RPC客户端发送对象到服务器,但无法得到响应。服务器无法以与客户端兼容的方式进行反序列化。所以我不能使用服务器回调回客户端。异常消息是这样的:


响应不能是
反序列化,
com.google.gwt.user

  @Entity 
@Table(name =course)
公共类课程实现Serializable {
private static final long serialVersionUID = 1L;
private int courseId;
私人字符串名称;
私人列表< Group>组;
私人列表<模块>模块;

public课程(){
}


@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@ Column(unique = true,nullable = false)
public int getCourseId(){
return this.courseId;
}

public void setCourseId(int courseId){
this.courseId = courseId;


$ b @Column(nullable = false,length = 100)
public String getName(){
return this.name;
}

public void setName(String name){
this.name = name;
}


//双向多对一关联到组
@OneToMany(mappedBy =course,fetch = FetchType.LAZY)
公开列表< Group> getGroups(){
return this.groups;
}

public void setGroups(List< Group> groups){
this.groups = groups;
}


//双向多对一关联到模块
@OneToMany(mappedBy =course,fetch = FetchType.LAZY)
public List< Module> getModules(){
返回this.modules;
}

public void setModules(List< Module> modules){
this.modules = modules;
}

}




  • 如果我删除关系,它的工作很好。这样做是因为像list,set等集合被转换成了无法由GWT客户端处理的hibernate对象。

我使用了 Gilead ,并解决了问题。



请检查相应的帖子:使用JPA的GWT


I use GWT and JPA for persistence. I have created a domain JPA enchanted classes, DAO's and RPC for communication between them. Everything works fine, through RPC the client sends the object to server but could not get response. Server cannot deserialize in a compatible way with the client side. So i cannot use the server callBack back to the client. The exception message is this:

The response could not be deserialized, com.google.gwt.user.client.rpc.SerializationException

Here's a sample code of one of my classes:

@Entity
@Table(name="course")
public class Course implements Serializable {
    private static final long serialVersionUID = 1L;
    private int courseId;
    private String name;
    private List<Group> groups;
    private List<Module> modules;

    public Course() {
    }


    @Id
    @GeneratedValue(strategy=GenerationType.IDENTITY)
    @Column(unique=true, nullable=false)
    public int getCourseId() {
        return this.courseId;
    }

    public void setCourseId(int courseId) {
        this.courseId = courseId;
    }


    @Column(nullable=false, length=100)
    public String getName() {
        return this.name;
    }

    public void setName(String name) {
        this.name = name;
    }


    //bi-directional many-to-one association to Group
    @OneToMany(mappedBy="course", fetch=FetchType.LAZY)
    public List<Group> getGroups() {
        return this.groups;
    }

    public void setGroups(List<Group> groups) {
        this.groups = groups;
    }


    //bi-directional many-to-one association to Module
    @OneToMany(mappedBy="course", fetch=FetchType.LAZY)
    public List<Module> getModules() {
        return this.modules;
    }

    public void setModules(List<Module> modules) {
        this.modules = modules;
    }

}

  • If i remove the relationships it work's fine. This is done because collections like lists, set's e.t.c are converted into hibernate objects that cannot be handled by GWT client side.

解决方案

I used Gilead and it fixed the issue.

Please check the corresponding post: GWT with JPA

这篇关于GWT JPA - 响应无法反序列化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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