You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
An Exception is thrown if OrderManagement.completeOrder fails because there is not enough stock to complete the order.
To my surprise is Order.isCompleted() equal to true after the failed call, which is not what I expected it to.
Interestingly, the change seems not to be stored and can be reversed with order = this.orders.get(order.getId()).get();.
The text was updated successfully, but these errors were encountered:
odrotbohm
changed the title
OrderManagement.completeOrder modifies Order on failureOrderManagement.completeOrder(…) modifies Order on failure
Nov 13, 2022
Unfortunately, JPA, the persistence mechanism leaves instances in the state to be modified, even if the transaction rolls back due to an exception. This means, that quite generally, you have to assume entities to be in an undefined state when an exception occurs and reload them through corresponding APIs, just as you already do.
I'll add a note to the Javadoc of OrderManagement.completeOrder(…) to warn about this.
odrotbohm
changed the title
OrderManagement.completeOrder(…) modifies Order on failureOrderManagement.completeOrder(…) still returns completed Order on failure
Nov 13, 2022
An Exception is thrown if
OrderManagement.completeOrder
fails because there is not enough stock to complete the order.To my surprise is
Order.isCompleted()
equal totrue
after the failed call, which is not what I expected it to.Interestingly, the change seems not to be stored and can be reversed with
order = this.orders.get(order.getId()).get();
.Maybe related to #23?
The text was updated successfully, but these errors were encountered: