I got a puzzling EntityExistsException in the following query -
TypedQuery<T> typedQuery = em.createQuery(query);
return result = typedQuery.getSingleResult(); // <-- exception thrown here
I thought this exception should normally occur when persisting, not when retrieving. Can you please shed some clues under which circumstances EntityExistsException can occur during a retrieval operation? Thanks.
javax.persistence.EntityExistsException: A different object with the same identifier value was already associated with the session : [...@d8e152db] at org.hibernate.jpa.spi.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1735) ~[hibernate-entitymanager-4.3.0.Final.jar:4.3.0.Final] at org.hibernate.jpa.spi.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1677) ~[hibernate-entitymanager-4.3.0.Final.jar:4.3.0.Final] at org.hibernate.jpa.internal.QueryImpl.getSingleResult(QueryImpl.java:524) ~[hibernate-entitymanager-4.3.0.Final.jar:4.3.0.Final] at org.hibernate.jpa.criteria.compile.CriteriaQueryTypeQueryAdapter.getSingleResult(CriteriaQueryTypeQueryAdapter.java:71) ~[hibernate-entitymanager-4.3.0.Final.jar:4.3.0.Final] ... ...