我想用一个自己类型的集合序列化一个对象,序列化没有问题,但是在反序列化对象doesent反序列化它的集合时,我有以下对象
package com.mars.distribution.model;
import java.io.Serializable;
import java.sql.Date;
import java.util.ArrayList;
import java.util.LinkedList;`
import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
@Entity
@Table(name="Intermediary_freeFlow",schema="distribution")
public class IntermediaryFreeFlow implements Cloneable,Serializable{
@Id
@GeneratedValue(strategy=GenerationType.SEQUENCE )
@Column(name="INTERM_ID")
private int intermId;
@OneToMany(cascade=CascadeType.ALL)
@JoinTable(name="INTERMEDIARY_FREEFLOW_RELATION",schema="distribution")
private List<IntermediaryFreeFlow> intermediaryCollection=new ArrayList<IntermediaryFreeFlow>();
public int getIntermId() {
return intermId;
}
public void setIntermId(int intermId) {
this.intermId = intermId;
}
public List<IntermediaryFreeFlow> getIntermediaryCollection() {
return intermediaryCollection;
}
public void setIntermediaryCollection(
List<IntermediaryFreeFlow> intermediaryCollection) {
this.intermediaryCollection = intermediaryCollection;
}
}
*
答案 0 :(得分:1)
您可以尝试在代码中使用ArrayList替换List。 Reason是ArrayList实现Serializable接口,其中List可能不是原因。