JPA: question about merging an entity before removing it

前端 未结 3 673
春和景丽
春和景丽 2021-02-08 07:33

I know I have to merge the entity before removing it, but I never thought I have to do it inside EJB. First I have these:

e = (Event) scholarBean.merge(e);
schol         


        
3条回答
  •  独厮守ぢ
    2021-02-08 07:43

    I had the same transaction-issues when this was used in a servlet. When using the EJB-service-bean from a MDB it worked fine, since the transaction was started before the EJB was called, but when the EJB-call came from a servlet, there was no running transaction. I solved this in my webapp by creating a filter that starts and commis a UserTransaction. Then every call to the EJB-methods joins my UserTransaction instead of starting it's own transaction.

提交回复
热议问题