Does it make sense to have static methods in stateless ejbs?
问题 Stateles ejbs are intended to be idempotent and have no memory of previous user interactions. That sounds like a static method to me. so instead of having public void save(Entity e) { em.persist(e); } is it safe to have public static void save(Entity e) { em.persist(e); } inside an EJB? 回答1: No, because static methods do not participate in container-managed transactions, AOP, security, etc. BTW your second example won't compile, em is injected by the application server and it can't be static