posted 6 years ago
I am trying to do delete and create of a pojo from inside the component. First I do the delete and then call save to create it again. The problem is that when the save fails, the delete isn't getting rollbacked.
This is the controller from where the component is called.
From itemComponent.save, itemDeleteAndCreate is called like this
Item updatedItem = itemDeleteAndCreate(itemToUpdate, itemId, item);
I have enabled transaction in my config through EnableTransactionManagement. I have also tried mode as AdviceMode.ASPECTJ but even that isn't helping.
Also I have tried writing wrapper class and putting this function in there and then creating an object of that class and calling this function on that object.
The Builder class eventually call Dao of crudRepository which also has a transactional annotation on its delete and save function.
This function is called from controller which doesn't have @transactional on it.
Also I have tried propagation level of acquires new but even that didn't work.
I have also tried rollbackfor Exception.class but even that doesn't work.
Any help would be appreciated.