I thought there was a getter for the Hibernate session object but there is just a setter in ProcessEngine. So if you create the hibernate session on your own and inject it into the Process Engine you can use the same session at the engine. I don't know if there is a reason for the missing getter.
P.S.: I assumed you were talking about jBPM 4.1.
I hate this forum for the impossibility to edit posts to correct typos!! :)
I can't inject the hibernate session.. i am doing this:
<bean id="processEngine" factory-bean="jbpmConfiguration" factory-method="buildProcessEngine" > <property name="hibernateSession" ref="jbpmSessionFactory"/> </bean>
and I get this error:
Caused by: org.springframework.beans.NotWritablePropertyException: Invalid property 'hibernateSession' of bean class [org.jbpm.pvm.internal.cfg.SpringConfiguration]: Bean property 'hibernateSession' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
I have no clue what could cause the error. I guess somebody more experienced with java beans can answer this.
Question to everyone else: Is there a reason that you can set but not get the Hibernate session?
wrong copy/paste... i am doing this:
<bean id="processEngine" factory-bean="jbpmConfiguration" factory-method="buildProcessEngine" > <property name="hibernateSessionFactory" ref="jbpmSessionFactory"/> </bean>
i think i know what is going on. the problem is that zhe hibernateSessionFactory setter is not a valid Java Beans seter.(has a return value).
Maybe someone could take a look and make jBPM a bit more Spring friendly.
I found the answer. it is actually quite simple. you can write your own Command and execute it . inside the execute Method from the Command you have access to the DBSession and you can execute Hibernate Queries. I will post an Example later on maybe if somone is interested.
I am implementing a command that returns a list of Tasks which have a specific name and belong to a process definition with a specific key and have variables with a specific value. maybe a command like this would be useful to everyone and can be integrated in jBPM task service.
I'm interested :)