Hi,
I'm writing a Swing gui. We have a search screen that runs a query in hibernate. The search is paginated and we use a SwingWorker. The first chunk of data comes in and we give it to the gui to display. This involves a jump onto the Event Dispatch Thread (EDT). The gui may require associations to be lazy loaded. We now have two threads accessing the same session, the 'search thread' and the EDT.
I can't think of a solution to solve this that preserves :
* not locking the gui when we do a search.
* not explicitly hydrating all associations needed for the gui to display.
does anyone have any ideas on how to solve this?
are there thread safe session implementations that we could use? Does it make sense to write one?
thanks, Don
ps. the stacktraces I'm getting are :
java.util.ConcurrentModificationException
at org.apache.commons.collections.SequencedHashMap$OrderedIterator.next(SequencedHashMap.java:757)
at org.hibernate.engine.StatefulPersistenceContext.afterTransactionCompletion(StatefulPersistenceContext.java:289)
at org.hibernate.impl.SessionImpl.afterTransactionCompletion(SessionImpl.java:444)
at org.hibernate.jdbc.JDBCContext.afterNontransactionalQuery(JDBCContext.java:224)
at org.hibernate.impl.SessionImpl.afterOperation(SessionImpl.java:437)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1134)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:79)
at org.springframework.orm.hibernate3.HibernateTemplate$29.doInHibernate(HibernateTemplate.java:807)
at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:356)
at org.springframework.orm.hibernate3.HibernateTemplate.find(HibernateTemplate.java:798)
at org.springframework.orm.hibernate3.HibernateTemplate.find(HibernateTemplate.java:794)
at it.orchestrate.oep.territory.hibernate.TerritoryDAOImpl.findAccountsForTerritories(TerritoryDAOImpl.java:46)
at it.orchestrate.oep.territory.TerritoryManagerImpl.findAccountsForTerritories(TerritoryManagerImpl.java:207)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:292)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:155)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:122)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
at it.orchestrate.oep.util.SessionInterceptor.invoke(SessionInterceptor.java:42)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:144)
at org.springframework.aop.interceptor.AbstractTraceInterceptor.invoke(AbstractTraceInterceptor.java:97)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:144)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:174)
at $Proxy10.findAccountsForTerritories(Unknown Source)
at it.orchestrate.oba.callplanning.LocationQuery.createCriteria(LocationQuery.java:67)
at it.orchestrate.oba.callplanning.LocationQuery.execute(LocationQuery.java:40)
at it.orchestrate.oba.searchview.SearchViewWorker.doInBackground(SearchViewWorker.java:75)
at it.orchestrate.oba.searchview.SearchViewWorker.doInBackground(SearchViewWorker.java:19)
at org.jdesktop.swingworker.SwingWorker$1.call(Unknown Source)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:269)
at java.util.concurrent.FutureTask.run(FutureTask.java:123)
at org.jdesktop.swingworker.SwingWorker.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:650)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:675)
at java.lang.Thread.run(Thread.java:595)
|