-
1. Re: Unable to dispose ksession
salaboy21 Jun 19, 2012 11:05 AM (in response to arselv)1 of 1 people found this helpfulare you using persistence right?
If you are using persistance you can dispose the session and load it back when you are sure that the thread that was using the session will not use it anymore.
Cheers
-
2. Re: Unable to dispose ksession
arselv Jun 19, 2012 11:27 AM (in response to salaboy21)Yeah thats right.I got your point.
But in my case the starting of a process and completion of it happens parallely.
And when i do so as u said. i'm getting this hibernate exception due to optimistic lock.
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)
and im looking for a way to clear this exception.
-
3. Re: Unable to dispose ksession
salaboy21 Jun 19, 2012 11:31 AM (in response to arselv)How do you usually solve a problem when you have 2 or more threads against 1 database that is locking?
I think that's the answer to your question.. sorry to answer with another question
Cheers
-
4. Re: Unable to dispose ksession
arselv Jun 19, 2012 11:58 AM (in response to salaboy21)For starting the process, the ksession associated with the taskhandler should be alive.
And by the same time during the completion of the task the ksession should be alive.
As both these shares the same taskhandler i couldnt dispose the ksession.
Hence i thought of having seperate taskhandlers one for starting a process and other for completing a task.
Thats in where i got that optimistic lock exception.
1. Cant i dispose the ksession with shared taskhandler.?
2. If i gotto use seperate taskhandlers, How to correct this exception.?
-
5. Re: Unable to dispose ksession
salaboy21 Jun 19, 2012 4:14 PM (in response to arselv)You can load the session and add a new instance of the task handler for the newly hydrated session, you don't need to share the WorkItemHandler between the two.
Cheers