I have two user Objects and while I try to save the object using
sessio.save(userObj)
I am getting the following error :
Caused by: org.hibernate.NonUniqueObjectException: a different object with the same identifier value was already associated with the session:
[com.pojo.rtrequests.User#com.pojo.rtrequests.User@d079b40b]
I am creating the session using
BaseHibernateDAO dao = new BaseHibernateDAO();
rtsession = dao.getSession(userData.getRegion(),
BaseHibernateDAO.RTREQUESTS_DATABASE_NAME);
rttrans = rtsession.beginTransaction();
rttrans.begin();
rtsession.save(userObj1);
rtsession.save(userObj2);
rtsession.flush();
rttrans.commit();
rtsession.close() // in finally block
I also tried doing the session.clear()
before saving, still no luck.
This is for the first I am getting the session object when a user request comes, so i am getting why is saying that object is present in session.
Any suggestions?