I donโt see a problem here, to be honest. First, why do you want to change orderId? The identifier must be set once, the other id is equal to a different object.
Usually, if you want to update an AR object, you just get it and update.
orderLine = order.getOrderLine(index) orderLine.changeProduct(someProduct)
If you need to store some invariants in AR, for example, that OrderLine.product must be unique, you call the AR method.
order.changeOrderLineProduct(orderLineIndex, someProduct)
Internally, this method checks if someProduct is unique, and if it then calls the code above. There is no DRY violation in this, the AR method checks the invariants, updates the orderLine method.
I would also think about using more UL in this, for example, "The customer changes the product to his custom line to order"
client.changeOrderLineProductOnOrder(orderLineIndex, product, order)
This way you can check if the customer is the owner of this order.
source share