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);
try{
pageCount = secArchiveDao.archive(pData);
sourceDao.deleteSourceData(pData);
secTxManager.commit(status);
success = true;
} catch (Exception ex)
{
secTxManager.rollback(status);
}
Exception:
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:
Thanks
Aadil