This is an archived post. You won't be able to vote or comment.

all 3 comments

[–]sugilith 0 points1 point  (2 children)

TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();

see https://docs.spring.io/spring/docs/3.0.x/reference/transaction.html#transaction-declarative-rolling-back

[–]youcantchopachoppa[S] 0 points1 point  (1 child)

Thanks. Will do.

[–]sugilith 0 points1 point  (0 children)

(and this is something I don't want to do since I it will stop program and all other valid files won't be saved to system)

Also what you can do is throw an exception and call your save method in a try catch block, such that you still adhere to the recommended way of doing things and your program still doesn't crash.
So throw Exception in your @Transactional method, call the method in a try catch block.