Spring and jBPM 4.3

Instead of using the following old jBPM 4.0 way, to inject those beans :

<bean id="jbpmConfiguration" p:sessionFactory-ref="sessionFactory">
  <constructor-arg value="jbpm.cfg.xml" />
<bean id="processEngine" factory-bean="jbpmConfiguration"
      factory-method="buildProcessEngine" />
<bean id="taskService" factory-bean="jbpmConfiguration"
      factory-method="getTaskService" />
<bean id="repositoryService" factory-bean="jbpmConfiguration"
      factory-method="getRepositoryService" />
<bean id="executionService" factory-bean="jbpmConfiguration"
      factory-method="getExecutionService" />
<bean id="historyService" factory-bean="jbpmConfiguration"
      factory-method="getHistoryService" />
<bean id="managementService" factory-bean="jbpmConfiguration"
      factory-method="getManagementService" />

jBPM 4.3 has a new Spring integration configuration :

<bean id="springHelper">
  <property name="jbpmConfiguration" value="jbpm.cfg.xml"/>
<bean id="processEngine" factory-bean="springHelper" 
      factory-method="createProcessEngine" />

In java classes, you can simply use :

private ProcessEngine processEngine;
ExecutionService executionService = processEngine.getExecutionService();

Mapping large String to Clob for Oracle with Hibernate and Spring

By default String mapping is limited to 4000 bytes in Oracle DB because of the VARCHAR2 type. You can leverage this restriction by storing larger String in a Clob type.

For doing this, you only have to change de text type used in Spring configuration to map your field. Using the ClobStringType will tell Hibernate to look for a Clob in the database.

This method is very useful and solve the problem of reading and writing String larger than 4000 bytes in the DB. In fact, while the content of the field was small, there wasn’t any problem, but with a larger one, Hibernate was not able to store it into the DB. Even if I tryed to store it with JDBC to see what was the problem, Hibernate couldn’t retrieve the stored field. It clearly was a problem of mapping.

Code :

.: To Complete :.

Let’s suppose we have the basic following class Book in our datamodel :

public class Book
    private String summary;
    public String getSummary() {
        return summary;

    public void setSummary(String summary) {
        this.summary = summary;

In our configuration file for hibernate, we find :

<bean id="lobHandler" lazy-init="true"/>

<bean id="mySessionFactory">
 <property name="dataSource" ref="myDataSource"/>
  <property name="mappingLocations">
  <property name="hibernateProperties">
    <prop key="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</prop>
    <property name="lobHandler" ref="lobHandler"/>

The hibernate-mapping.hbm.xml gives us :

<class name=”Book” table=”book”>
<id name=”id” type=”integer” unsaved-value=”null”>
<param name=”sequence”>book_id_seq</param>

<property name=”summary” type=”org.springframework.orm.hibernate3.support.ClobStringType”/>