User development,
A new message was posted in the thread "How to get sub process instance id":
http://community.jboss.org/message/523064#523064
Author : Santanu Saraswati
Profile :
http://community.jboss.org/people/saraswati.santanu
Message:
--------------------------------------------------------------
Giuseppe,
I am really surprised. I tried in multiple ways, but I always get correct values in
"executions" collection. I have gone thourgh the queries fired and the
hibernate mapping of ExecutionImpl and everything justifies that.
When you call this:
ProcessInstance mainProcessInstance =
(ProcessInstance)executionService.findProcessInstanceById(mainProcessInstanceId);
These are the queries which gets fired:
select * from ( select executioni0_.DBID_ as DBID1_0_, executioni0_.DBVERSION_ as
DBVERSION3_0_, executioni0_.ACTIVITYNAME_ as ACTIVITY4_0_, executioni0_.PROCDEFID_ as
PROCDEFID5_0_, executioni0_.HASVARS_ as HASVARS6_0_, executioni0_.NAME_ as NAME7_0_,
executioni0_.KEY_ as KEY8_0_, executioni0_.ID_ as ID9_0_, executioni0_.STATE_ as
STATE10_0_, executioni0_.SUSPHISTSTATE_ as SUSPHIS11_0_, executioni0_.PRIORITY_ as
PRIORITY12_0_, executioni0_.HISACTINST_ as HISACTINST13_0_, executioni0_.PARENT_ as
PARENT14_0_, executioni0_.INSTANCE_ as INSTANCE15_0_, executioni0_.SUPEREXEC_ as
SUPEREXEC16_0_, executioni0_.SUBPROCINST_ as SUBPROC17_0_ from JBPM4_EXECUTION
executioni0_ where executioni0_.ID_=? ) where rownum <= ?
and a number of
select executions0_.PARENT_ as PARENT14_1_, executions0_.DBID_ as DBID1_1_,
executions0_.PARENT_IDX_ as PARENT18_1_, executions0_.DBID_ as DBID1_0_0_,
executions0_.DBVERSION_ as DBVERSION3_0_0_, executions0_.ACTIVITYNAME_ as ACTIVITY4_0_0_,
executions0_.PROCDEFID_ as PROCDEFID5_0_0_, executions0_.HASVARS_ as HASVARS6_0_0_,
executions0_.NAME_ as NAME7_0_0_, executions0_.KEY_ as KEY8_0_0_, executions0_.ID_ as
ID9_0_0_, executions0_.STATE_ as STATE10_0_0_, executions0_.SUSPHISTSTATE_ as
SUSPHIS11_0_0_, executions0_.PRIORITY_ as PRIORITY12_0_0_, executions0_.HISACTINST_ as
HISACTINST13_0_0_, executions0_.PARENT_ as PARENT14_0_0_, executions0_.INSTANCE_ as
INSTANCE15_0_0_, executions0_.SUPEREXEC_ as SUPEREXEC16_0_0_, executions0_.SUBPROCINST_ as
SUBPROC17_0_0_ from JBPM4_EXECUTION executions0_ where executions0_.PARENT_=?
The first one is to load the process inastance whose id you passed and the other ones are
for the child execution(s) of that (please note the where clause of the second query). And
if your sub process instance exists then one of the executions will have the name as that
of the transition you made to reach the sub process. In the sub process execution object
you will find the execution for your wait state.
The queries to load childen execution instance are made because in hibernate mapping
they are non lazy. Here is the snippet of the hibernate mapping (note lazy=false here):
<list name="executions"
cascade="all-delete-orphan"
inverse="false"
lazy="false">
<key column="PARENT_" foreign-key="FK_EXEC_PARENT" />
<list-index column="PARENT_IDX_" />
<one-to-many class="ExecutionImpl" />
</list>
I am sure that it gives the correct list. I tried with Oracle and PostgreSQL (though
does not make sense, but still to check if there is any db dependency), but for both I
got the same behaviour.
About LazyInitializationException - if you are conversant with hibernate, then you
already know that hibernate proxy objects are bound to a session. Once the session is
closed they become orphan and become useless. So the probable reason for getting the
exception is if you get the main object (here the mainProcessINstance object) in one
session and try to get the proxy in another session (or out of the session). You may need
to look at the transaction boundaries. Wrong transaction boundary will close the session
at a wrong place.
If you can give some more detail of your implementation then I can try. I am pretty
sure it works.
--------------------------------------------------------------
To reply to this message visit the message page:
http://community.jboss.org/message/523064#523064