使用容器管理的EntityManager进行会话管理

时间:2015-09-18 09:04:07

标签: java hibernate jpa apache-karaf karaf

需要懒洋洋地获取一个集合。如果我然后尝试访问其组件,我会得到以下异常:

failed to lazily initialize a collection of role:
 mapp3.model.ProductDefinition, could not initialize proxy - no Session

所以我用这样的方式从entityManager中检索了会话:

Session session = entityManager.unwrap(Session.class);

但这会导致以下异常:

Error executing command: Transaction management is not available for container managed EntityManagers.

我在Karaf容器中使用Hibernate。我怎样才能继续浏览延迟获取的集合,或者使用容器管理的EntityMananger启动会话?

0 个答案:

没有答案
相关问题