-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: org.hibernate.NonUniqueObjectException in Criteria.list
PostPosted: Fri Dec 29, 2006 4:47 pm 
Newbie

Joined: Tue Dec 12, 2006 3:27 pm
Posts: 2
Hi folks,

I've been using Hibernate for several months now and I'm usually able to get by seemingly obscure errors and I've learned some of the trade offs with Hibernate. But this one is completely mistery:

session.createCriteria(prototype.getClass()).add(Example.create(prototype)).list();

gives me:

org.hibernate.NonUniqueObjectException: a different object with the same identifier value was already associated with th
e session:

'prototype' in the above call is a simple POJO with no associations whatsoever. Here is its config:

<class table="PORTT_MDC_I18N_RESOURCES" name="gov.miamidade.i18n.MessageResource">
<id name="id" column="MDC_I18N_ID">
<generator class="sequence">
<param name="sequence">PORTSQ_HIBERNATE_SEQUENCE</param>
</generator>
</id>
<property name="key" column="MDC_I18N_KEY" />
<property name="bundle" column="MDC_I18N_BUNDLE" />
<property name="language" column="MDC_I18N_LANGUAGE" />
<property name="text" column="MDC_I18N_TEXT" type="text"/>
</class>

I understand that I might already have loaded some of the objects matching my prototype, but why do I need to worry about that when making a query? In all my code I pay special attention to do merge/save/update when appropriate, but this is a simply query that's supposed to be handled properly by Hibernate.

Any idea?

Thanks a lot in advance!
Borislav

PS I'm using Hibernate version 3.1.3, March 20, 2006


Top
 Profile  
 
 Post subject:
PostPosted: Sat Dec 30, 2006 4:46 am 
Expert
Expert

Joined: Tue Dec 28, 2004 7:02 am
Posts: 573
Location: Toulouse, France
Are you sure this is the session.createCriteria(...) code that triggers this exception? What is the stacktrace? Maybe try calling session.flush(); before your code to see if it has something to do with something not yet synced.

Calling session.clear() before your code should remove the problem, but I understand you'd like to understand what's going on, before doing such thing which I think you know from what you say about your experience.

Please let us know about if you find the origin of the problem.

_________________
Baptiste
PS : please don't forget to give credits below if you found this answer useful :)


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.