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: Reposting:Requesting Help with "Found two representatio
PostPosted: Thu Dec 06, 2007 2:53 pm 
Newbie

Joined: Tue Jun 21, 2005 6:52 pm
Posts: 4
Hi All,

I am getting this error and unable to resolve it. I found that there is a JIRA for this: http://opensource.atlassian.com/project ... se/HHH-511

and the JIRA says that it was resolved in 3.2, but I am not sure why we get this error. There was a patch for this posted by Rodrigo which says the following:


Quote:
Rodrigo S. de Castro - [08/Aug/06 03:00 PM ]
Patch against Hibernate 3.1.3

Apply it with: patch -p1 -i ./reattach-same-session.patch

I developed this patch to fix two problems I faced when reattaching objects to the session after clearing it:

- "reassociated object has dirty collection reference"
- "Found two representations of same collection: (collection type)"

This patch fixes this problem by allowing an object from a given session to be reattached. To do that, there are two minor changes in two classes:

- OnLockVisitor: in processCollection(), when a collection has been attached to the same session, we only throw an exception if the collection is dirty, otherwise we reattach this collection to the session and move on.

- Collections: in processReachableCollection() method, when a given collection is not found in the session persistence context, we check if it is a collection that has been previously attached to the session. If it is, we add this collection back to the persistence context. That fixes "Found two representations..." problem.


I am not sure whether the patch went into 3.2, but I see that the code for Collections still shows this from 3.2.5.ga:

Code:
public static void processReachableCollection(PersistentCollection collection, CollectionType type, Object entity, SessionImplementor session)
        throws HibernateException
    {
        collection.setOwner(entity);
        CollectionEntry ce = session.getPersistenceContext().getCollectionEntry(collection);
        [b]if(ce == null)
            throw new HibernateException("Found two representations of same collection: " + type.getRole());[/b]        if(ce.isReached())
            throw new HibernateException("Found shared references to a collection: " + type.getRole());
        ce.setReached(true);
        SessionFactoryImplementor factory = session.getFactory();
        CollectionPersister persister = factory.getCollectionPersister(type.getRole());
        ce.setCurrentPersister(persister);
        ce.setCurrentKey(type.getKeyOfOwner(entity, session));
        if(log.isDebugEnabled())
            log.debug("Collection found: " + MessageHelper.collectionInfoString(persister, ce.getCurrentKey(), factory) + ", was: " + MessageHelper.collectionInfoString(ce.getLoadedPersister(), ce.getLoadedKey(), factory) + (collection.wasInitialized() ? " (initialized)" : " (uninitialized)"));
        prepareCollectionForUpdate(collection, ce, session.getEntityMode(), factory);
    }


As shown by the code, in processReachableCollection(), if the CollectionEntry is not found in the PersistentContext, the "Found two representations of same collection:..." HibernateException is thrown.

I am not an expert in Hibernate. I would really appreciate if anyone can let me know the cause and solution to this problem.

Thanks,
S


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 06, 2007 3:46 pm 
Newbie

Joined: Tue Jun 21, 2005 6:52 pm
Posts: 4
Just to add to that:

I have an EmptyInterceptor for capturing History and we have a history entity that has a *collection* of changes. I am getting this error when the transaction is being committed. The "Found two representations of same collection" is being thrown on this HistoryEntity.changes collection.

Thanks,
S


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.