Accessing Hibernate Session in JBPM 3

This tutorial has been written for an old version of jBPM which is now deprecated.

If you want to get started quickly with jBPM, we recommend the following quickstarts:

Using Hibernate Session in JBPM 3 is quite simple, all you need is retrieving the Hibernate Session from the JbpmContext interface.

Below is a sample code which delete all process instances, by iterating on the ProcessInstance List:

public void deleteProcessInstances() {
JbpmContext context = JbpmConfiguration.getInstance().createJbpmContext();
try {
Session hibernateSession = context.getSession();

Query processQuery = hibernateSession.createQuery("from org.jbpm.graph.exe.ProcessInstance pi ");

List instances = (List) processQuery.list();

if (instances != null && instances.size() > 0) {
  for (ProcessInstance instance : instances) {
    long id = instance.getId();

finally {