Friday, December 27, 2013

org.hibernate.NonUniqueObjectException



org.hibernate.NonUniqueObjectException

Problem:
The Hibernate's exception org.hibernate.NonUniqueObjectException: a different object with the same identifier value was already associated with the session is a very difficult one to track down, because the exception occurs in a code's place not related to where the problem first occurred. What the exception is saying is that an object with the same id is already loaded inside the Hibernate session.

You can get this exception while calling below method

System.out.println(getSession().getStatistics().getEntityKeys());
This will display all the objects loaded in the session.

0 comments: