我試圖使用與GWT前端延遲加載JPA [休眠]JPA [休眠]延遲加載與GWT問題
在實體
@ManyToOne(targetEntity = Item.class,fetch=FetchType.LAZY)
private Item item;
在DAO
@Transactional
public List<Purchase> findAllPurchases() {
return jpaTemplate.execute(new JpaCallback<List<Purchase>>(){
public List<Purchase> doInJpa(EntityManager em)
throws PersistenceException {
List<Purchase> list = em.createQuery("select o from Purchase o").getResultList();
for(Purchase p:list){
Item item = p.getItem();
if(item!=null)
item.getItemName();
}
return list;
}
}); }
我收到此錯誤。
com.google.gwt.user.client.rpc.SerializationException:類型「com.hardwarestore.vo.Item _ _ $$ javassist_0」沒有被包括在該組的類型,其可以通過將本SerializationPolicy或其被序列Class對象無法加載。出於安全目的,這種類型不會被序列化。實例= [email protected]
購買類和Item類都實現Serializable接口。任何形式的幫助表示讚賞。謝謝。
同樣的問題是解決[這裏](http://stackoverflow.com/questions/3397475/hibernate-serialization-exception-in-gwt-but-eclipselink-not/3398839#3398839)和[there](http ://stackoverflow.com/questions/1778578/lazy-eager-loading-strategies-in-remoting-cases-jpa/1778625#1778625)。 – 2011-10-13 08:53:15