Rerunning failed Container-Managed transactions in Java EE

I have a situation with a legacy system which uses Java EE Bean Managed Transactions. It's getting `LockAcquisitionException` thrown when it's trying to retrieve something it just created. My initial thoughts were this: @TransactionAttribute(SUPPORTS) public Item retrieveItem(int id) { Item i; try { i = em.find(Item.class, id); } catch (PersistenceException e) { if (e.getCause() instanceof LockAcquisitionException) { i = retrieveItem(id); } } return i; } However - when the recursive call is made, the transaction has already died - and it doesn't seem to create a new one. I've tried different `TransactionAttributes`, but it doesn't seem to make a difference. Also tried managing the transaction myself (`em.getTransaction()`), but that's illegal in CMT. I'm not looking for an elegant fix - as I said, this is legacy, I just need something that will triage it until the whole thing gets replaced in a couple of months! Cheers.

以上就是Rerunning failed Container-Managed transactions in Java EE的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » JavaScript 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准

联系我们

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏