This content has been marked as final. Show 4 replies
commit your changes after you delete.
You can try to post changes to db(with yourAM.getTransaction().postChanges() ) or to clear entity cache(with yourAM.getTransaction.clearEntityCache("full path to your Entity')
If you have define primary key for you table Copy lines and commit may cause to the Error,As Dario said you can use postChanges() for every transaction and if error occurred update record proper way and finally do commit if all transactions are valid.
The unquie contraint is not from the primary key. There are three columns in the table (batch_id, line_number, line_type) which must be unique. In the UI, the user can delete lines, update lines and add lines and finally click the save button that does the commit. On delete the line_number gets re-numbered. So when committing, the unique error occurs because the line number already exists. Looks like insert is happening before update/delete. I cannot do commit after each delete/update/insert. I have to do it only if the user clicks the save button in the end. Is there a way to control the order of execution?