对于EJB懒加载时,由于没有hibernate中的opensessionview,那么需要在会话结束之前就加载数据,可以选择在dao层实现,代码如下:

 

public TBLDeliveryWarrant find1(String id) throws ServiceException {
try {
TBLDeliveryWarrant deliveryWarrant = deliveryWarrantDao.find(id);
Set<TBLGoods> goods = deliveryWarrant.getGoods();
if (goods != null && goods.size() > 0) {
for (TBLGoods good : goods) {
good.getCargoJT();
}
}
deliveryWarrant.getContainers().size();         //加载集装箱信息
deliveryWarrant.getGodownWarrant().getCode();  //加载单子对应的货物

return deliveryWarrant;
} catch (DAOException e) {
logger.error(e);
throw new ServiceException("", e);
}
}

相关文章:

  • 2021-12-28
  • 2021-09-21
  • 2021-09-21
  • 2022-12-23
  • 2021-12-03
  • 2018-10-16
  • 2021-09-21
猜你喜欢
  • 2022-12-23
  • 2021-12-08
  • 2021-10-24
  • 2021-12-08
  • 2022-12-23
  • 2020-10-10
相关资源
相似解决方案