将 Pojo 组件转换为 EJB3
来在组件中使用扩展的 PersistenceContext ,
@PersistenceContext(type=PersistenceContextType.EXTENDED)
EntityManager entityManager;
我尝试通过添加In order to use this Seam 迫使我将该组件作为有状态会话 Bean (SFSB) 删除。为了满足要求,我必须为 SFSB 的方法创建一个接口,甚至是在 EntityHome
和 Home
中声明的方法,这是正确的(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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(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? andEntityManager 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 extendedPersistenceContext
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...