我有3个类,推荐,判断,用户,关系是:一个推荐可能有多个判断,一个用户可能有多个判断(根据不同的推荐),这是我的JPA类:
班级推荐
@Entity
@Table(name = "RECOMMENDATIONS")
public class Recommendation implements Serializable, Cloneable {
...
@OneToMany(cascade = {CascadeType.REFRESH, CascadeType.DETACH }, fetch = FetchType.EAGER, mappedBy="recommendation", targetEntity=Judgement.class)
private Set<Judgement> judgements;
...
public Recommendation() {
super();
this.judgements = new LinkedHashSet<Judgement>();
}
...
}
班级用户:
@Table(name = "USERS", uniqueConstraints = @UniqueConstraint(columnNames = "email"))
public class User implements Serializable, Cloneable {
...
@OneToMany(mappedBy="judge", targetEntity=Judgement.class, cascade = { CascadeType.REFRESH, CascadeType.DETACH }, fetch = FetchType.EAGER)
private Set<Judgement> judgements;
...
public User() {
super();
this.judgements = new LinkedHashSet<Judgement>();
}
...
}
班级判断:
@Entity
@Table(name = "JUDGEMENTS")
public class Judgement implements Serializable, Cloneable {
@ManyToOne(cascade = { CascadeType.REFRESH, CascadeType.DETACH})
@JoinColumn(name = "id")
private Recommendation recommendation;
@ManyToOne(cascade = { CascadeType.REFRESH, CascadeType.DETACH})
@JoinColumn(name = "user_id")
private User judge;
...
public Judgement() {
super();
}
...
}
在 db 中,我有以下表格:用户推荐;判断;
我在用户中有一些数据,在推荐中有一些数据,但在判断表中为空,当我加载我的应用程序时出现以下异常:
com.google.gwt.user.client.rpc.SerializationException: Type 'org.hibernate.collection.PersistentSet' 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 = []
我调试了加载推荐记录的判断字段时出现的代码,它无法实例化它。请帮忙!