Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

org.hibernate.NonUniqueObjectException

Posted on 2013-01-07
1
Medium Priority
?
375 Views
Last Modified: 2013-01-17
Hi All,

Please advise on what we should do to prevent the following exception.

-10.60.5.39-8643-8) MKOCO95200M42Q0 : a different object with the same identifier value was already associated with the session: web.enrollment.bean.organization.EnrollmentAccomodationsBean#308: org.hibernate.NonUniqueObjectException: a different object with the same identifier value was already associated with the session: web.enrollment.bean.organization.EnrollmentAccomodationsBean#308
0
Comment
Question by:somaghoshCU
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 10

Accepted Solution

by:
ivanovn earned 900 total points
ID: 38764767
The Java objects and Hibernate objects are handled differently. In this case, you have opened a hibernate session and associated an object to that identifier. So when you try to merge in a new java object within the same hibernate session, that identifier is already used in hibernate cache and you get that exception.

What you should do is either complete the merge of the initial object and close or clear the session, or evict the hibernate object from the cache before reusing the identifier.

Chapter 11 of the documentation contains most of the information you need:
http://docs.jboss.org/hibernate/orm/4.1/manual/en-US/html/ch11.html

For the rest of the documentation see:
http://docs.jboss.org/hibernate/orm/4.1/manual/en-US/html/
0

Featured Post

How To Reduce Deployment Times With Pre-Baked AMIs

Even if we can't include all the files in the base image, we can sometimes include some of the larger files that we would otherwise have to download, and we can also sometimes remove the most time-consuming steps. This can help a lot with reducing deployment times.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
The viewer will learn how to implement Singleton Design Pattern in Java.
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question