In many cases, we want to persist entities occurring in workflows in a relational database. YAWL has a mechanism called Data Gateway allowing us to store and fetch data directly from a relational database without using net variables.

In this tutorial, we show how YAWL Data Gateways and Hibernate can be used in conjunction. We perform these steps:

  1. Create a relational database in PostgreSQL.
  2. Write a YAWL Data Gateway using Hibernat.
  3. Specify a YAWL workflow to use the Data Gateway.

Create a relational database in PostgreSQL.

We create a database "messagerepository" owned by user "postgres" with password "postgres". We create a table "message" with two columns using the attached "sqlScript". When filled with values the table will look like this:

filled table

The idea here is that messages will be created by the user during the execution of the workflow cases and that the unique id will be generated by Hibernate.

Write a YAWL Data Gateway using Hibernate.

The following code has been adapted from a Hibernate course by Peggy Fisher.

We are using Netbeans as an IDE. We import the Netbeans project from yawlDataGatewayHibernate.zip and add the attached jar-files to the Libraries. The resulting project should look like this:

Netbeans project

After successfully building the project, there should be a file called yawlDataGatewayHibernate.jar in the "dist" folder of Netbeans. This file should be copied to the YAWL-4.2/engine/apache-tomcat-7.0.65/webapps/yawl/WEB-INF/lib folder. This allows YAWL to retrieve the Data Gateway called "MyDBGatewayImpl".

Specify a YAWL workflow to use the Data Gateway.

Now we create a simple workflow specification like this:

The specification

 

In the first task, the user enters a message text like this:

The first form

 

This message text is directly stored in the database table "message" using Hibernate. In the second task, all messages stored so far are displayed like this:

The second form