Hibernate/Spring Boot: How to exclude an entity from rollback

It is very likely since you freezing the database, not your app. You are trying to insert a record that is already trying to be inserted in another transaction before the other transaction is completed. Which is likley taking the database from a row lock to a full table lock. So each transaction is waiting on the other to close before they can move forward.

You can try one of these:

1.  Fully roll back and complete the first transaction before trying to redo the insert.   Since you are still in the exception processing logic holding the exception from being thrown Spring Batch will not have rolled back the transaction for that step yet.

2.  Try to do the the extra insert in one of Spring Batch's onError() listeners.

3.  Do the insert into a separate temp table (you can create as the start of the job, and delete at the end of the job.) and use an onComplete() listener for the step to then copy any entries in that temp table to your intended table.