Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

NonUniqueObjectException exception coming

 
shikhaj jainy
Ranch Hand
Posts: 35
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Ranchers,

Hope you all are doing well.
I am using hibernate and spring in application and coming across one hibernate exception.

Through logs I can see:
Caused by: org.hibernate.NonUniqueObjectException: a different object with the same identifier value was already associated with the session:
at org.springframework.orm.hibernate3.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:661)
at org.springframework.orm.hibernate3.HibernateAccessor.convertHibernateAccessException(HibernateAccessor.java:412)
at org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:424)
at org.springframework.orm.hibernate3.HibernateTemplate.executeWithNativeSession(HibernateTemplate.java:374)
at org.springframework.orm.hibernate3.HibernateTemplate.saveOrUpdateAll(HibernateTemplate.java:764)

This is coming when I am adding fresh new objects to database.

I did some googling, people suggested that in case of detached objects while calling saveOrUpdateAll() method will throw this error , but here I am using fresh new objects; I am not able to figure out the reason .Can you please suggest me some solution other than merge(because adding fresh objects).


Thank You.
Shikha


 
Ravishanker kumar
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This may expected reason for this exception...
Same object is already present in the session.
Please cross check the flow between opening and closing the session.
it may be possible you have retrieved the same object before in same session.

~Ravi
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic