I save Listusing sleep mode, but it throws the following exception:
org.hibernate.NonUniqueObjectException: a different object with the same identifier value was already associated with the session:
The code I'm using is below, but I don't know why it throws an exception:
public void save(List<UserItem> list)
{
sessFactory = getHibernateTemplate().getSessionFactory();
Session session = sessFactory.getCurrentSession();
for (UserItem bean : list) {
session.saveOrUpdate(bean);
}
}
What is the correct way to save List?
source
share