• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
  • Mikalai Zaikin

HELP !!! Illegal use of List across sessions exception

Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
To all Spring/Hibernate Gurus,

I am using the following code(in bold), but I get an exception when i try to delete the data from the sourceDao within the transaction(exception is given below). I even tried copying data to a different list before passing it to the delete method, but it still gives the same exception.

Remember, the copying part is not in the transaction. It only has writing to one database and deleting from the copied database(so read only trxs dont work). Is there a way I could manually detach the list from the first session??

pData = sourceDao.getSourceData(startDate, endDate);

DefaultTransactionDefinition def = new DefaultTransactionDefinition();
def.setPropagationBehavior(TransactionDefinition.P ROPAGATION_REQUIRED);
TransactionStatus status = this.secTxManager.getTransaction(def);

pageCount = secArchiveDao.archive(pData);
success = true;

} catch (Exception ex)


org.springframework.orm.hibernate3.HibernateSystem Exception: Illegal attempt to associate a collection with two open sessions; nested exception is org.hibernate.HibernateException: Illegal attempt to associate a collection with two open sessions
org.hibernate.HibernateException: Illegal attempt to associate a collection with two open sessions
at org.hibernate.collection.AbstractPersistentCollect ion.setCurrentSession(AbstractPersistentCollection .java:237)
at org.hibernate.event.def.OnUpdateVisitor.processCol lection(OnUpdateVisitor.java:41)
at org.hibernate.event.def.AbstractVisitor.processVal ue(AbstractVisitor.java:104)
at org.hibernate.event.def.AbstractVisitor.processVal ue(AbstractVisitor.java:64)
at org.hibernate.event.def.AbstractVisitor.processEnt ityPropertyValues(AbstractVisitor.java:58)
at org.hibernate.event.def.AbstractVisitor.process(Ab stractVisitor.java:129)
at org.hibernate.event.def.DefaultDeleteEventListener .onDelete(DefaultDeleteEventListener.java:74)
at org.hibernate.impl.SessionImpl.delete(SessionImpl. java:579)
at org.springframework.orm.hibernate3.HibernateTempla te$26.doInHibernate(HibernateTemplate.java:703)
at org.springframework.orm.hibernate3.HibernateTempla te.execute(HibernateTemplate.java:312)
at org.springframework.orm.hibernate3.HibernateTempla te.deleteAll(HibernateTemplate.java:699)
at org.tiaa.secarchive.dao.impl.SecProductionCltDAOIm pl.deleteSourceData(SecProductionCltDAOImpl.java:7 6)
at org.tiaa.secarchive.delegate.impl.SecArchiveDelega teImpl.archive(SecArchiveDelegateImpl.java:86)
at org.tiaa.secarchive.schedule.impl.JobImpl.archive( JobImpl.java:328)
at org.tiaa.secarchive.schedule.impl.JobImpl.execute( JobImpl.java:210)
at org.tiaa.secarchive.schedule.impl.DaemonImpl.run(D aemonImpl.java:239)
at java.lang.Thread.run(Thread.java:534)
org.tiaa.j2eeinfra.exception.TiaaRuntimeException: There are no open seeds in the database. New Seeds need to be created !
at org.tiaa.secarchive.schedule.impl.JobImpl.checkSee dsAvailability(JobImpl.java:415)
at org.tiaa.secarchive.schedule.impl.JobImpl.execute( JobImpl.java:80)
at org.tiaa.secarchive.schedule.impl.DaemonImpl.run(D aemonImpl.java:239)
at java.lang.Thread.run(Thread.java:534)

Any help is greatly appreciated:
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
    Bookmark Topic Watch Topic
  • New Topic