【发布时间】:2020-03-23 11:45:42
【问题描述】:
我开发和应用程序使用 JPA 和无状态 EJB。基本上,应用程序包括负责实现业务案例的 EJB 以及负责从底层数据库中获取和删除数据的 EJB。
例子:
public interface UserContextAccessEJBLocal {
/**
* Persists the passed instance of {@link UserContex}.
*
* @param userContext an instance of {@link UserContext}
* @throws NullPointerException if userContext is null.
* @throws IOException if an I/O related error occurs.
*/
void remove(UserContext userContext)
throws IOException;}
我的问题:如果在 EJB A 中获取 JPA 实体并将其传递给 EJB B,我是否可以假设传递的实例属于由注入 B 的 EntityManager 管理的持久性上下文,或者我必须提取它的 ID 重新取回了吗?
关于我的问题,无状态和有状态 EJB 有区别吗?
【问题讨论】: