I've used Hibernate for a little while now and have become accustomed to most of the common error messages. Most point me straight to the problem, but I've been having issues with this one:
org.hibernate.NonUniqueObjectException: a different object with the same identifier value was already associated with the session
I understand the error (the session has two different objects with the same ID), but I don't really know of a good way to debug my code to find the source of the issue. Usually, I look at the code that I'm currently changing and look for places where I load one object and manually create another, hoping that I can find a simple error in my logic. However, I'm currently working with a code set that I didn't write, that am not familiar with, and that has no documentation. The only solution that I can think of is to go through the code, line by line, hoping to find the error. Do you know of a better way to debug this error?
Additionally, the exact error that I'm getting is from a call to saveOrUpdate()
, which makes me wonder if it is calling save()
when it should be calling update()
. Is there any way to look at the objects that Hibernate has in the current Session for debugging purposes?