Is it okay to pass injected EntityManagers to EJB bean's helper classes and use it?

后端 未结 3 1107
梦毁少年i
梦毁少年i 2020-12-29 01:02

We have some JavaEE5 stateless EJB bean that passes the injected EntityManager to its helpers.

Is this safe? It has worked well until now, but I found out some Ora

3条回答
  •  独厮守ぢ
    2020-12-29 01:27

    I've been using helper methods and passed the EntityManager there, and it is perfectly OK.

    So I'd recommend either passing it to methods whenever needed, or make the helper a bean itself, inject it (using @EJB) and inject the EntityManager there as well.

提交回复
热议问题