我有一个EJB和JPA的应用程序:
ActionService
@Stateless
public class ActionService {
@EJB
private ActionDao actionDao
@PersistenceContext
protected EntityManager em;
public Action create(Action x) {
return actionDao.create(x);
}
public foo businessLogic() {
em.createQuery(...)
}
@Stateless
public class ActionDao {
@PersistenceContext
protected EntityManager em;
protected T create(final T t) {
this.em.persist(t);
return t;
}
}
经过调试后,我发现EntityManager
(ActionService
,ActionDao
}都有不同的身份。这是一个问题/这会成为一个问题吗?