[Fixed] Hibernate Error: a different object with the same identifier value was already associated with the session(lazy load)
Before:
public boolean updateUserStory(UserStory userStory) { try { Session session = sessionFactory.getCurrentSession(); session.update(userStory); return true; } catch (HibernateException e) { e.printStackTrace(); return false; } }
After:
@Transactional(readOnly = false, propagation = Propagation.REQUIRES_NEW) public boolean updateUserStory(UserStory userStory) { try { Session session = sessionFactory.getCurrentSession(); session.merge(userStory); return true; } catch (HibernateException e) { e.printStackTrace(); return false; } }
References:
Advertisements
Posted on 07/12/2013, in Fix Lỗi, Tham Khảo and tagged hibernate lazy, lazy load. Bookmark the permalink. Bạn nghĩ gì về bài viết này?.
Bạn nghĩ gì về bài viết này?
Comments 0