JPA: pattern for handling OptimisticLockException

后端 未结 4 1514
隐瞒了意图╮
隐瞒了意图╮ 2020-12-14 08:33

what is the correct pattern for handling OLE in a (REST) web service? this is what i\'m doing now, for example,

protected void doDelete(HttpServletRequest re         


        
4条回答
  •  一个人的身影
    2020-12-14 09:03

    If you're just going to keep retrying until it works anyway, why not just disable optimistic locking? You should let the caller know that they made a decision based on out dated information! If you're in control of both sides an appropriate 400 code can be returned. If it's public it can be more friendly to arbitrary clients to just return 500. (Of course then you perpetuate the under-use of appropriate response codes! such a dilemma)

提交回复
热议问题