Accessing Hibernate Session in JBPM 3

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 {


Related articles available on

JBPM tutorial

JBoss jBPM 3 is a flexible, extensible framework for process lang

How do I fire an action every time a JBPM Node enters?

JBoss recipe of the day

JBoss Jbpm superstates

What is a superstate ? a Superstate is a group of nodes. Supersta

Jbpm Mail delivery

Almost every workflow needs a notification of the process activit

How do you embed Java code in your JPDL ?

  You can use a BeanShell expression to add a Java script in you

JBPM best practices

There's no perfect rule to model your workflow, it depends on the

Follow us on Twitter