java.io.invalidClassException:org.hibernate.collection.PersistentSet:Incompatible class(SUID)错误
pojo类代码(以user为例)package com.demo.hibernate.beans;import java.io.Serializable;
import java.util.Date;
import java.util.Set;
import org.apache.commons.lang.builder.ToStringBuilder;
/** @author Hibernate CodeGenerator */
public class User implements Serializable { /** identifier field */
private Integer userId; /** persistent field */
private String userName; /** nullable persistent field */
private String password; /** nullable persistent field */
private byte[] picture; /** nullable persistent field */
private Date lastLogout; /** persistent field */
private Set albums; /** persistent field */
private Set comments; /** persistent field */
private Set photos; /** persistent field */
private Set friends; /** full constructor */
public User(Integer userId, String userName, String password, byte[] picture, Date lastLogout, Set albums, Set comments, Set photos, Set friends) {
this.userId = userId;
this.userName = userName;
this.password = password;
this.picture = picture;
this.lastLogout = lastLogout;
this.albums = albums;
this.comments = comments;
this.photos = photos;
this.friends = friends;
} /** default constructor */
public User() {
} /** minimal constructor */
public User(Integer userId, String userName, Set albums, Set comments, Set photos, Set friends) {
this.userId = userId;
this.userName = userName;
this.albums = albums;
this.comments = comments;
this.photos = photos;
this.friends = friends;
} public Integer getUserId() {
return this.userId;
} public void setUserId(Integer userId) {
this.userId = userId;
} public String getUserName() {
return this.userName;
} public void setUserName(String userName) {
this.userName = userName;
} public String getPassword() {
return this.password;
} public void setPassword(String password) {
this.password = password;
} public byte[] getPicture() {
return this.picture;
} public void setPicture(byte[] picture) {
this.picture = picture;
} public Date getLastLogout() {
return this.lastLogout;
} public void setLastLogout(Date lastLogout) {
this.lastLogout = lastLogout;
} public Set getAlbums() {
return this.albums;
} public void setAlbums(Set albums) {
this.albums = albums;
} public Set getComments() {
return this.comments;
} public void setComments(Set comments) {
this.comments = comments;
} public Set getPhotos() {
return this.photos;
} public void setPhotos(Set photos) {
this.photos = photos;
} public Set getFriends() {
return this.friends;
} public void setFriends(Set friends) {
this.friends = friends;
} public String toString() {
return new ToStringBuilder(this)
.append("userId", getUserId())
.toString();
}}
这个是用插件自动根据数据库表自动生成的POJO类 如上貌似没用到出错的类不明白为何出这个错。而且所有的pojo类我都有第三方工程从新导出bean.jar的包 分别有服务器java web project和客户端android引用了呢。出这个错之前是这个类没找到,我查到这个类出现在hibernate3.jar所以我在客户端又加了这个类,结果出现这个类错误。。结果我对照源代码 没错啊貌似服务器端如果hibernate生成的pojo的类 不能直接传递给客户端 那怎么解决呢。。目前服务器全部用Hibernnate搭建的 难道要改成一般的jdbc形式吗??哎 或者在服务器把里面的set取出来转化成list再放进新对象再传 避免用到这个类??都是笨方法 有没有先进点儿的 谢谢在座的高手了 离项目成功就差一步了。。
pojo类代码(以user为例)package com.demo.hibernate.beans;import java.io.Serializable;
import java.util.Date;
import java.util.Set;
import org.apache.commons.lang.builder.ToStringBuilder;
/** @author Hibernate CodeGenerator */
public class User implements Serializable { /** identifier field */
private Integer userId; /** persistent field */
private String userName; /** nullable persistent field */
private String password; /** nullable persistent field */
private byte[] picture; /** nullable persistent field */
private Date lastLogout; /** persistent field */
private Set albums; /** persistent field */
private Set comments; /** persistent field */
private Set photos; /** persistent field */
private Set friends; /** full constructor */
public User(Integer userId, String userName, String password, byte[] picture, Date lastLogout, Set albums, Set comments, Set photos, Set friends) {
this.userId = userId;
this.userName = userName;
this.password = password;
this.picture = picture;
this.lastLogout = lastLogout;
this.albums = albums;
this.comments = comments;
this.photos = photos;
this.friends = friends;
} /** default constructor */
public User() {
} /** minimal constructor */
public User(Integer userId, String userName, Set albums, Set comments, Set photos, Set friends) {
this.userId = userId;
this.userName = userName;
this.albums = albums;
this.comments = comments;
this.photos = photos;
this.friends = friends;
} public Integer getUserId() {
return this.userId;
} public void setUserId(Integer userId) {
this.userId = userId;
} public String getUserName() {
return this.userName;
} public void setUserName(String userName) {
this.userName = userName;
} public String getPassword() {
return this.password;
} public void setPassword(String password) {
this.password = password;
} public byte[] getPicture() {
return this.picture;
} public void setPicture(byte[] picture) {
this.picture = picture;
} public Date getLastLogout() {
return this.lastLogout;
} public void setLastLogout(Date lastLogout) {
this.lastLogout = lastLogout;
} public Set getAlbums() {
return this.albums;
} public void setAlbums(Set albums) {
this.albums = albums;
} public Set getComments() {
return this.comments;
} public void setComments(Set comments) {
this.comments = comments;
} public Set getPhotos() {
return this.photos;
} public void setPhotos(Set photos) {
this.photos = photos;
} public Set getFriends() {
return this.friends;
} public void setFriends(Set friends) {
this.friends = friends;
} public String toString() {
return new ToStringBuilder(this)
.append("userId", getUserId())
.toString();
}}
这个是用插件自动根据数据库表自动生成的POJO类 如上貌似没用到出错的类不明白为何出这个错。而且所有的pojo类我都有第三方工程从新导出bean.jar的包 分别有服务器java web project和客户端android引用了呢。出这个错之前是这个类没找到,我查到这个类出现在hibernate3.jar所以我在客户端又加了这个类,结果出现这个类错误。。结果我对照源代码 没错啊貌似服务器端如果hibernate生成的pojo的类 不能直接传递给客户端 那怎么解决呢。。目前服务器全部用Hibernnate搭建的 难道要改成一般的jdbc形式吗??哎 或者在服务器把里面的set取出来转化成list再放进新对象再传 避免用到这个类??都是笨方法 有没有先进点儿的 谢谢在座的高手了 离项目成功就差一步了。。
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货