将 Pojo 组件转换为 EJB3

发布于 2024-10-03 18:45:28 字数 339 浏览 0 评论 0原文

来在组件中使用扩展的 PersistenceContext ,

@PersistenceContext(type=PersistenceContextType.EXTENDED)
    EntityManager entityManager;

我尝试通过添加In order to use this Seam 迫使我将该组件作为有状态会话 Bean (SFSB) 删除。为了满足要求,我必须为 SFSB 的方法创建一个接口,甚至是在 EntityHomeHome 中声明的方法,这是正确的(Seam)方式吗?

I tried to use an extended PersistenceContext in a component by adding

@PersistenceContext(type=PersistenceContextType.EXTENDED)
    EntityManager entityManager;

In order to use this Seam forces me to delcare the component as a Stateful Session Bean (SFSB). To meet the requirements I have to create an interface for SFSB's methods even the methods declared in EntityHome<E> and Home<E> is this the right (Seam) way?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

从 Seam 的角度来看,使用扩展的 PersistenceContext 是可以的。您还可以阅读这两个参考资料,了解使用它的优点和缺点: When do I use @In vs @PersistenceContext to Inject an EntityManager?
EntityManager注入:@PersistenceContext或@In??

由于 Home 是会话范围,因此我会尝试从该范围中受益以获得扩展的持久性上下文。尽管使用扩展的PersistenceContext 没问题,但是对话范围肯定更多的是“Seam-way”。但是,由于我不知道您想要完成什么,因此对话范围可能不合适......

From a Seam point-of-view, it's OK using the extended PersistenceContext. You can also read these two references for pros and cons of using it: When do I use @In vs @PersistenceContext to inject an EntityManager? and
EntityManager injection: @PersistenceContext or @In ??
.

Since Home<E> is conversation scoped, I would try to benefit from that scope to get an extended persistence context. Although, using an extended PersistenceContext is fine, the conversation scope this is definitely more the 'Seam-way'. However, since I'm not aware of what you want to accomplish, the conversation-scope might not be approperiate...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文