1
我有3個班,推薦,判斷,用戶的關係是:一個建議,可能有多個的判斷,一個用戶可能有多個判斷(在不同的建議),這裏是我的JPA類:冬眠PersistentenSet沒有被列入類型的集合
類建議
@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 = []
我調試的代碼竟然當負載的判斷場對於推薦記錄,它不能實例化它。請幫忙!含有數據庫實體,其通過裝載休眠
這是一個與GWT相關的問題,如例外所示。我在你的問題中加了gwt標籤。 –
這看起來像是來自GWT的錯誤,而不是Hibernate。另外,你應該在'User'中添加'@ Entity'註釋 –