//場景:使用了延遲加載, //所以使用了org.springframework.orm.hibernate3.support.OpenSessionInViewFilter //現在又一個request得到后台A有一個children屬性,現在給A對象的children中添加一個child,調用的是action中的save方法(save中保存child). //當添加完成以后,在action中resultType為chain,跳轉到list方法,list方法又查詢了A對象的信息。這個時候如果不this.getSession().refresh(obj); //則查詢不到A對象中包含child的信息. public Object getById() { Object obj = this.getSession().get(Object.class, id); this.getSession().flush();// 先把數據更新到數據庫 this.getSession().refresh(obj);//把把對象更新為和數據庫一致 return obj; }