I create a ksession for every processinstance.
The process instances are created without any problem.But when i complete the task of the process instances.
Im getting this exception
javax.persistence.OptimisticLockException: org.hibernate.StaleObjectStateException: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect): [org.drools.persistence.info.SessionInfo#1]
at org.hibernate.ejb.AbstractEntityManagerImpl.wrapStaleStateException(AbstractEntityManagerImpl.java:630)
at org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException(AbstractEntityManagerImpl.java:588)
I understand that another thread is trying to access a row which is already deleted from the table after completing it.
But I have to use multiple ksessions. How would i use those without getting this exception.
I have attached the class files for reference.