简体   繁体   English

来自Pojo的Java-EE远程调用ejb事务

[英]Java-ee remote calling ejb transaction from pojo

I'm facing a problem calling an EJB (which persist entites) from a remote client via "Context lookup" and then doing different transactions. 我遇到了一个问题,即通过“上下文查找”从远程客户端调用EJB(持久存在的实体),然后执行不同的事务。 Each time I'm calling the statefull container managed EJB it commits and not rolling back in case of an error. 每次我调用有状态容器管理的EJB时,它都会提交,并且在发生错误时不会回滚。 My Pseudo-Code: 我的伪代码:

Calling the remote-EJB persist method: 调用remote-EJB持久方法:

transactionController.persist(getCurrentEntity());

Where transactionController was set via "Context lookup". 通过“上下文查找”设置transactionController的位置。

And my EJB: 而我的EJB:

@Remote

    @Stateful(name = "TransactionController")
    public class TransactionController {
        @PersistenceContext
        EntityManager entityManager;

        public void persist(Object object){
            entityManager.persist(object);
        }

Is it possible managing transactions within the containter when calling it from a pojo (remote)? 从pojo(远程)调用容器时,是否可以在容器中管理事务? How can i solve this? 我该如何解决?

If you are calling an ejb and want to manage the transaction( eg rollback on exception). 如果您正在调用ejb并想要管理事务(例如,异常回滚)。 you can do explicit transaction management. 您可以执行显式事务管理。 which involves marking the transaction boundaries explicitly. 这涉及明确标记交易边界。 Explicit transaction management 显式交易管理

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM