Win a copy of Spring Boot in Practice this week in the Spring forum!
  • 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
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

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(
at org.hibernate.event.def.AbstractVisitor.processVal ue(
at org.hibernate.event.def.AbstractVisitor.processVal ue(
at org.hibernate.event.def.AbstractVisitor.processEnt ityPropertyValues(
at org.hibernate.event.def.AbstractVisitor.process(Ab
at org.hibernate.event.def.DefaultDeleteEventListener .onDelete(
at org.hibernate.impl.SessionImpl.delete(SessionImpl. java:579)
at org.springframework.orm.hibernate3.HibernateTempla te$26.doInHibernate(
at org.springframework.orm.hibernate3.HibernateTempla te.execute(
at org.springframework.orm.hibernate3.HibernateTempla te.deleteAll(
at pl.deleteSourceData( 6)
at teImpl.archive(
at There are no open seeds in the database. New Seeds need to be created !
at dsAvailability(

Any help is greatly appreciated:
Don't get me started about those stupid light bulbs.
    Bookmark Topic Watch Topic
  • New Topic