Spring, Hibernate - org.springframework.retry.RetryException: Non-skippable exception in recoverer while processing; nested exception is org.hibernate.NonUniqueObjectException: A different object with the same identifier value was already associated with the session

July 25, 2016

Problem:

org.springframework.retry.RetryException: Non-skippable exception in recoverer while processing; nested exception is org.hibernate.NonUniqueObjectException: A different object with the same identifier value was already associated with the session

Solution 1:

http://stackoverflow.com/questions/3609653/hibernate-error-org-hibernate-nonuniqueobjectexception-a-different-object-with

Solution 2:

This was the one that worked for me. Make sure to create a new object instead of reusing and old one and setting new values into it:

records.setJob(feedJob); records.setProcessedRecords(seenFeedProducts.size()); feedJobRecordsDAO.save(records); 

vs.

records = new FeedJobRecords(); records.setJob(feedJob); records.setProcessedRecords(seenFeedProducts.size()); 
feedJobRecordsDAO.save(records);