-->
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: Query in Multithreaded apps: Shared references exception
PostPosted: Fri Aug 29, 2008 2:17 pm 
Newbie

Joined: Wed Jul 30, 2008 8:00 am
Posts: 3
Hibernate version: 3.2.5.ga

Code between sessionFactory.openSession() and session.close():

Caused by: org.hibernate.HibernateException: Found shared references to a collection: library.impl.LibraryImpl.books
at org.hibernate.engine.Collections.processReachableCollection(Collections.java:163)
at org.hibernate.event.def.FlushVisitor.processCollection(FlushVisitor.java:37)
at org.hibernate.event.def.AbstractVisitor.processValue(AbstractVisitor.java:101)
at org.hibernate.event.def.AbstractVisitor.processValue(AbstractVisitor.java:61)
at org.hibernate.event.def.AbstractVisitor.processEntityPropertyValues(AbstractVisitor.java:55)
at org.hibernate.event.def.DefaultFlushEntityEventListener.onFlushEntity(DefaultFlushEntityEventListener.java:138)
at org.hibernate.event.def.AbstractFlushingEventListener.flushEntities(AbstractFlushingEventListener.java:196)
at org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:76)
at org.hibernate.event.def.DefaultAutoFlushEventListener.onAutoFlush(DefaultAutoFlushEventListener.java:35)
at org.hibernate.impl.SessionImpl.autoFlushIfRequired(SessionImpl.java:969)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1114)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:79)
at org.hibernate.ejb.QueryImpl.getResultList(QueryImpl.java:64)


Name and version of the database you are using: Oracle11g


When we query our database for any children of the LibraryImpl (ex: LibrayImpl.employees), we sometime get the exception above. But this exception occurs only when our application has multithread querying and persisting object to the database. When run in single thread, no exception occurs.

I don't understand why this exception occurs at query time.

Also :
The collection LibraryImpl.books is empty for all the instance of LibraryImpl in the datase. Why would we have a shared reference on a empty list set once by the constructor of the LibraryImpl?

We use Enhanced.id.SequenceStyleGenerator with increment-by set to 200. As a test I subclassed SequenceStyleGenerator and added the synchronized key word. I still randomly get the exception.

This is not the solution but problems goes away with this collection setter:
Code:
   public void setBooks(List<Book> books)
   {
          this.books = new ArrayList<Book>(books);
    }


We reviewed our model and there is no issue related to this post:
http://forum.hibernate.org/viewtopic.php?p=2273553


Anyone has a clue of what could be going on?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 29, 2008 3:45 pm 
Newbie

Joined: Wed Jul 30, 2008 8:00 am
Posts: 3
I found the issue.

We just refactored our code from TENEO to pure Hibernate and one our persisting strategy was missing a entityManager.close()... finding a needle in a hay stack...


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.