Solved

org.hibernate.NonUniqueObjectException

Posted on 2013-01-07
1
332 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
1 Comment
 
LVL 10

Accepted Solution

by:
ivanovn earned 300 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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
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.

757 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now