-->
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.  [ 4 posts ] 
Author Message
 Post subject: Found two representations of same collection
PostPosted: Wed Jan 11, 2006 6:05 am 
Newbie

Joined: Sat Apr 30, 2005 10:58 am
Posts: 3
Hi,

i'm facing to the same problem than http://forum.hibernate.org/viewtopic.ph ... 00#2231400 eventhough i'm not clearing the session.

Here is the code snippet :

Code:
            try {
                SnapShot snapShotClone = (SnapShot) BeanUtils.cloneBean(pIdentifiedObject);
                //recursive method to mark all children
                markSnapShot(snapShotClone, pUser, pIdentifiedObject.getId());
                session = snapShotLocalSessionFactoryBean.getSnapShotSessionFactory().openSession();
                transaction = session.beginTransaction();
                session.save(snapShotClone);
                transaction.commit();
                return snapShotClone;
            } catch (Exception e) {
                try {
                    transaction.rollback();
                } catch (Exception e1) {
                    logger.error(e1.getMessage());
                }
                throw new SnapShotException(e);
            } finally {
                try {
                    session.close();
                } catch (Exception e) {
                    logger.error(e.getMessage());
                }
            }




And at stackTrace we can see Session is flushed :

[code]
Caused by: net.sf.hibernate.HibernateException: Found two representations of same collection
at net.sf.hibernate.impl.SessionImpl.updateReachableCollection(SessionImpl.java:2866)
at net.sf.hibernate.impl.FlushVisitor.processCollection(FlushVisitor.java:32)
at net.sf.hibernate.impl.AbstractVisitor.processValue(AbstractVisitor.java:69)
at net.sf.hibernate.impl.AbstractVisitor.processValues(AbstractVisitor.java:36)
at net.sf.hibernate.impl.SessionImpl.flushEntity(SessionImpl.java:2588)
at net.sf.hibernate.impl.SessionImpl.flushEntities(SessionImpl.java:2454)
at net.sf.hibernate.impl.SessionImpl.flushEverything(SessionImpl.java:2256)
at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2235)
at net.sf.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:61

[code]


In Hibernate JIRA, it' s adviced to evict the object but didn' t even loaded it before and din' t called session.clear() !!!

How should i fix this ?

Thank you in advance ![/code]


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 11, 2006 7:55 am 
Newbie

Joined: Wed Jan 11, 2006 7:42 am
Posts: 2
These errors are very anoying because error messages don't tell which collection or in which entity is collection located. I've found that the easiest way to resolve these (and other some kind of errors like 'collection was evicted' etc.) is to add some debugging information about collection and entity names in hibernate source code and recompile whole package.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 11, 2006 9:36 am 
Newbie

Joined: Sat Apr 30, 2005 10:58 am
Posts: 3
No you don't need to recompile the whole hibernate !!!!!!

Just use 2.1.7 version then hibernate says which collection is impacted.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 11, 2006 9:40 am 
Newbie

Joined: Wed Jan 11, 2006 7:42 am
Posts: 2
I'm using hibernate 3


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.