-->
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: ConcurrentModificationException and caching?
PostPosted: Sat Jan 05, 2008 6:25 am 
Newbie

Joined: Thu Dec 21, 2006 7:30 am
Posts: 11
Hi -

I having difficulties understanding the source of a ConcurrentModificationException I am observing.

The code region
Code:
try
            {
               logger.debug("Creating query");
               List<Object> list = session.createQuery(query).setCacheable(true).list();
               logger.debug("Query OK ");
               logger.debug("List null : "+ (list == null));
               logger.debug("List size : "+list.size());
               
               for (Object object : list)
               {
                  logger.debug("Adding from list to set");
                  set.add((T) object);
               }
               logger.debug("DONE, everything looks OK...");
            }
            catch (JDBCConnectionException e){
               logger.error("getAll() cought Exception");
               logger.error(e.getMessage());
               logger.error(e.getCause());
               logger.error(e);
               logger.error("JDBCConnectionException IS UNMANAGEBEL!!!");
               logger.error("--- Restarting server !!! ---");
               System.out.println("getAll() cought Exception");
               System.out.println(e.getMessage());
               System.out.println(e.getCause());
               System.out.println(e);
               System.out.println("JDBCConnectionException IS UNMANAGEBEL!!!");
               System.out.println("--- Restarting server !!! ---");
               System.exit(0);
            }
            catch (Exception e)
            {
               logger.error("getAll() cought Exception");
               logger.error(e.getMessage());
               logger.error(e.getCause());
               logger.error(e);
               logger.error("Session was null : "+(session == null));
               logger.error("Session is open : "+session.isOpen());
               logger.error("Query is: "+query);
               logger.error("Re-trying query : ");
               try{
                  List<Object> list = session.createQuery(query).setCacheable(true).list();
                  logger.error("Query OK ");
                  logger.error("List null : "+ (list == null));
                  logger.error("List size : "+list.size());
               
                  for (Object object : list)
                  {
                     logger.error("Adding from list to set");
                     set.add((T) object);
                  }
                  logger.error("DONE, everything looks OK...");
                  } catch (Exception innerEx){
                     logger.error("getAll() (retry) cought Exception");
                     logger.error(innerEx.getMessage());
                     logger.error(innerEx.getCause());
                     logger.error(innerEx);
                  }
               //Well, we failed...
               throw new InternalServerError(e);
            }


Error log from the first catch clause and forward:
Code:
2007-11-26 12:23:18,416 ERROR reflection.AEntity - getAll() cought Exception
2007-11-26 12:23:18,417 ERROR reflection.AEntity -
2007-11-26 12:23:18,417 ERROR reflection.AEntity -
2007-11-26 12:23:18,417 ERROR reflection.AEntity - java.util.ConcurrentModificationException
2007-11-26 12:23:18,417 ERROR reflection.AEntity - Session was null : false
2007-11-26 12:23:18,417 ERROR reflection.AEntity - Session is open : true
2007-11-26 12:23:18,417 ERROR reflection.AEntity - Query is: from integration.hibernate.IntegrationMapEntry where entityPattern='/SURGERYROOM/2029'
2007-11-26 12:23:18,417 ERROR reflection.AEntity - Re-trying query :
2007-11-26 12:23:18,444 ERROR reflection.AEntity - Query OK
2007-11-26 12:23:18,445 ERROR reflection.AEntity - List null : false
2007-11-26 12:23:18,445 ERROR reflection.AEntity - List size : 14
2007-11-26 12:23:18,445 ERROR reflection.AEntity - Adding from list to set
2007-11-26 12:23:18,445 ERROR reflection.AEntity - Adding from list to set
2007-11-26 12:23:18,445 ERROR reflection.AEntity - Adding from list to set
2007-11-26 12:23:18,445 ERROR reflection.AEntity - Adding from list to set
2007-11-26 12:23:18,445 ERROR reflection.AEntity - Adding from list to set
2007-11-26 12:23:18,445 ERROR reflection.AEntity - Adding from list to set
2007-11-26 12:23:18,445 ERROR reflection.AEntity - Adding from list to set
2007-11-26 12:23:18,445 ERROR reflection.AEntity - Adding from list to set
2007-11-26 12:23:18,445 ERROR reflection.AEntity - Adding from list to set
2007-11-26 12:23:18,445 ERROR reflection.AEntity - Adding from list to set
2007-11-26 12:23:18,445 ERROR reflection.AEntity - Adding from list to set
2007-11-26 12:23:18,445 ERROR reflection.AEntity - Adding from list to set
2007-11-26 12:23:18,445 ERROR reflection.AEntity - Adding from list to set
2007-11-26 12:23:18,445 ERROR reflection.AEntity - Adding from list to set
2007-11-26 12:23:18,445 ERROR reflection.AEntity - DONE, everything looks OK...
2007-11-26 12:23:19,012 ERROR reflection.AEntity - getAll() cought Exception
2007-11-26 12:23:19,012 ERROR reflection.AEntity -
2007-11-26 12:23:19,012 ERROR reflection.AEntity -
2007-11-26 12:23:19,012 ERROR reflection.AEntity - java.util.ConcurrentModificationException
2007-11-26 12:23:19,012 ERROR reflection.AEntity - Session was null : false
2007-11-26 12:23:19,012 ERROR reflection.AEntity - Session is open : true
2007-11-26 12:23:19,012 ERROR reflection.AEntity - Query is: from integration.hibernate.IntegrationMapEntry where entityPattern='/SURGERYROOM/2028'
2007-11-26 12:23:19,012 ERROR reflection.AEntity - Re-trying query :
2007-11-26 12:23:19,018 ERROR reflection.AEntity - getAll() (retry) cought Exception


Could it have something to do with the query.setCacheable?

Only one session is used.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 25, 2008 3:28 am 
Newbie

Joined: Thu Dec 21, 2006 7:30 am
Posts: 11
I found out what coursed the error. It was because the session flush mode was set to auto. Setting it to commit resolved the issue.


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.