Solved

org.hibernate.NonUniqueObjectException

Posted on 2013-01-07
1
337 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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
wordsWithoutList  challenge 24 120
json example 39 148
why cannot we forward request once the response is committed 2 42
jboss wildfly 10.1 10 81
I had a project requirement for a displaying a user workbench .This workbench would consist multiple data grids .In each grid the user will be able to see a large number of data. These data grids should allow the user to 1. Sort 2. Export the …
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…
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.

786 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