I\'m having some trouble using Persistence on my jBPM project.
My configuration is jBPM 5.4 + Hibernate + JPA 2, and I\'m currently setting up the process flow to co
Ok, so here goes a little tutorial to configure persistence in JBPM, using a MySQL database and JBoss AS:
1) Create a META-INF folder under your src/main/java folder
2) Create persistence.xml
org.hibernate.ejb.HibernatePersistence
java:/your_data_source_name
META-INF/JBPMorm.xml
META-INF/ProcessInstanceInfo.hbm.xml
org.drools.persistence.info.SessionInfo
org.jbpm.persistence.processinstance.ProcessInstanceInfo
org.drools.persistence.info.WorkItemInfo
3) Create orm.xml
select
processInstanceInfo.processInstanceId
from
ProcessInstanceInfo processInstanceInfo
where
:type in elements(processInstanceInfo.eventTypes)
4) Create ProcessInstanceInfo.hbm.xml
5) Now you have to define your datasource. I use JBoss5, and this version of JBoss will read any file with the pattern *-ds.xml as being the definition of your datasource. You have to put this file in your deploy folder (and you may notice there's already a datasource file there, but there will be no conflicts). If you're using JBoss7, there's a different way to define the DS - I suppose this might be helpful https://community.jboss.org/wiki/DataSourceConfigurationInAS7.
Anyway, here's what your yourDS-ds.xml should look like:
jdbc/your_datasource_name
your_db_url
com.mysql.jdbc.Driver
your_user
your_pass
5
20
5
6) The above instructions are enough to at least create the persistence tables in the database. When you eventually start using tasks in JBPM, it may be required to create a Taskorm.xml file (google it, it's too long). I'm not sure if it's necessary, but I have it anyway.
7) Finally, just call your persistence unit in Java through the EntityManagerFactory, create your environment and start a new session. The persistence data should be automatically saved to the DB.
Hope this was helpful. Cheers!