I've isolated the problem.
Just creating the Query
select pl from org.jbpm.logging.log.ProcessLog as pl where pl.token = :token order by pl.index
(this is from LoggingsSession.findLogsByToken() ) already throws a HibernateException: instance not of expected entity type: org.jbpm.graph.def.Action. So data isn't the problem. I don't even get that far.
Still gratefull for any hints.
This one was bizarr!
Hibernate does an autoflush when createQuery is called (I don't know if this always happens but in this case it did and to find out I had to trace 15 stacklevels of Hibernate code)
As I have some 'transient' objects in the current processInstance (I remove them before persisting, see Thread on RuntimeActions) this caused the excpetion. Setting session.setFlushMode( Commit ) did the trick.
You are truely a champion in solving your own problems! Anyway it is great that you keep us posted on your struggles.
Thanks a lot and regards,
by default hibernate will flush before it executes a query. that is normal cause the modified data related to your session could be involved in the query. and the query is executed in the db. that's why hibernate has to flush at query time.
anyways. some very impressive digging !
is there anything we could do in the jbpm code to handle this situation ?
sorry for the panic, but I was working against the clock and willing to take any humiliation connected with stupid questions :-) Speed was all that mattered.
What surprised me was that it was tested code that threw up this problem. I was just playing around with some very rare scenarios in the lull before final deployment and all of a sudden it goes doom! I haven't yet figured out what caused the change (and it wasn't realy a priority.)
No there is nothing you should(!) do in jBPM code as the flushing is correct behaviour if you take 2 minutes to think about it, but thanks for asking. The root cause of the problem was my 'magic' adding transient runtime actions to the processInstance on the fly. I remove all instances + the corresponding logs before saving the processInstance, but that wasn't enough or rather soon enough in this case.
You missed out on a case of beer though. That would have been the next level of coaxing :-)
sorry for the panic, but I was working against the clock and willing to take any humiliation connected with stupid questions :-)
I would say you deserve bonus points instead of humiliation ;-)
You missed out on a case of beer though.
This is a pity though... Our thirst is legendary ;-)