This problem is caused by using transaction attribute
Required for the setForeignKey() method for table A instead of
using the recommended transaction attribute of RequiresNew.
When the delete method is called, an attempt is made to remove the record
from the database immediately. The UPDATE does not occur until after the
transaction ends. Therefore, the operations are out of order.
The solution is to set the transaction attribute to RequiresNew, which,
creates a new transaction and forces the update to occur before the
delete.
|