2014-09-05 38 views
0

我嘗試使用簡單的冬眠碼刷新我的實體關係時:如何刷新休眠實體與其他實體

session.refresh(myEntity); 

問題是。這個實體有關係的其他實體:

class MyEntity{ 

    private OtherEntity otherEntity: 

} 

當我第一次加載對象我使用像查詢:

Query query = getSession().createQuery("from myEntity mEnt" 
     + " join fetch mEnt.otherEntity"); 

全部被加載。但是當我刷新對象。

session.refresh(myEntity); 

關係實體(otherEntity)未加載,爲空。我正在使用LAZY初始化。

任何人都知道如何解決它?我會很感激的幫助。

+0

是你的實體'MyEntity'' cacheable' – 2014-09-05 09:49:55

回答