私は春と休止状態の小さなGWTアプリケーションを開発したいが、MySql dbからリストを取得中にエラーが発生する。エンティティクラスContactはRoomと@ManyToOneの関係を持っています。GWT rpc.SerializationException hibernate ManyToOneリレーションシップオブジェクト
@Entity
@Table(name = "contact")
public **class Contact** extends LightEntity implements java.io.Serializable {
@Id
@Column(name = "id")
protected int id;
@Column(name = "firstname")
protected String firstname;
@Column(name = "telephone")
protected String telephone;
@ManyToOne
@JoinColumn(name = "ROOM_ID")
protected Room room;
...セッターとゲッター
@Entity
@Table(name = "ROOM")
public **class Room** extends LightEntity implements java.io.Serializable {
@Id
@GeneratedValue
@Column(name = "ROOM_ID")
private int id;
@Column(name = "ROOM_NUMBER")
protected int rnr;
@OneToMany(mappedBy="room", fetch = FetchType.EAGER) // tried to fetch eagerly
private List<Contact> contacts;
...セッターとゲッター
expainedとして、私は唯一のユニを使用する場合LightEntityは記事にhttps://developers.google.com/web-toolkit/articles/using_gwt_with_hibernate?hl=fr-FR
使用されています。方向(つまり@ManyToOneで部屋へのコンタクト)関係は正常に動作します。ここで
が例外である: -
Hibernate: select contacts0_.ROOM_ID as ROOM6_1_1_, contacts0_.id as id1_, contacts0_.id as id0_0_, contacts0_.email as email0_0_, contacts0_.firstname as firstname0_0_, contacts0_.lastname as lastname0_0_, contacts0_.ROOM_ID as ROOM6_0_0_, contacts0_.telephone as telephone0_0_ from contact contacts0_ where contacts0_.ROOM_ID=?
Starting Jetty on port 8888
[WARN] Exception while dispatching incoming RPC call
com.google.gwt.user.client.rpc.SerializationException:
Type 'org.hibernate.collection.PersistentBag' 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 = [[email protected], [email protected], [email protected], [email protected], [email protected]]
at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter.serialize(ServerSerializationStreamWriter.java:619)
すべてのヘルプやアドバイスをいただければ幸いです。
種類のよろしく、私にとって ABID
まず最初: は、あなたが空のコンストラクタを持っていますかこのクラスのために? GWTのシリアル化は必須です。 –
はい両方のエンティティクラスに空のコンストラクタがあります。 – user1227806