如何在没有LazyInitializationException的情况下接收实体?

时间:2015-08-20 08:08:52

标签: hibernate lazy-initialization

我有两个实体:

  A
  id bigint auto_inctement
  b_id bigint

  B
  id bigint
  date timestamp

和代码:

// Client rectangle in screen coordinates
Rectangle rc = MyControl.RectangleToScreen(MyControl.ClientRectangle);

// Let's align context menu (its width) to bottom of the control
MyContextMenuStrip.AutoSize = false;
// Depending on actual dropdown control you may want align either via
//   Width = rc.Width;
// Or 
//   ClientSize = new Size(rc.Width, someHeight);
MyContextMenuStrip.Width = rc.Width;

// Let's show context menu at the bottom of the control
MyContextMenuStrip.Show(new Point(rc.Left, rc.Bottom));

如何正确接收b.getDate()? (没有懒惰="渴望")

1 个答案:

答案 0 :(得分:1)

在会话结束后尝试获取数据时,您可以尝试使用:

Hibernate.initialize(b.getDate())

这里有一些更多细节http://docs.jboss.org/hibernate/core/3.5/reference/en/html/performance.html#performance-fetching-initialization

相关问题