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 connect to a DB with persistence, through persistence.xml. I'm just trying to connect the default data source (in the H2 server) with my custom persistence.xml, but I keep getting the same error over and over again:
Unknown entity: org.jbpm.persistence.processinstance.ProcessInstanceInfo
I've manually added to my src/META-INF folder the JBPMorm-JPA2.xml the following content, but the error still persists. Can anyone help me?
JBPMorm-JPA2.xml:
<?xml version="1.0" encoding="UTF-8"?>
<entity-mappings xmlns="http://java.sun.com/xml/ns/persistence/orm"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm orm_2_0.xsd"
version="2.0">
<named-query name="ProcessInstancesWaitingForEvent">
<query>
select
processInstanceInfo.processInstanceId
from
ProcessInstanceInfo processInstanceInfo join processInstanceInfo.eventTypes eventTypes
where
eventTypes = :type
</query>
</named-query>
<!-- ProcessInstanceInfo mapping (needed for JPA 2) -->
<entity class="org.jbpm.persistence.processinstance.ProcessInstanceInfo"
metadata-complete="true">
<pre-update method-name="update" />
<attributes>
<id name="processInstanceId">
<column name="InstanceId" />
<generated-value strategy="AUTO"/>
</id>
<basic name="processId" access="FIELD" />
<basic name="startDate" access="FIELD" >
<temporal>DATE</temporal>
</basic>
<basic name="lastReadDate" access="FIELD" >
<temporal>DATE</temporal>
</basic>
<basic name="lastModificationDate" access="FIELD" >
<temporal>DATE</temporal>
</basic>
<basic name="state" access="FIELD" />
<basic name="processInstanceByteArray" access="FIELD" >
<lob/>
</basic>
<version name="version" access="FIELD" >
<column name="OPTLOCK" />
</version>
<element-collection name="eventTypes" target-class="java.lang.String" access="FIELD" >
<collection-table name="EventTypes">
<join-column name="InstanceId"/>
</collection-table>
</element-collection>
<transient name="processInstance" />
<transient name="env" />
</attributes>
</entity>
</entity-mappings>
persistence.xml:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<persistence
version="1.0"
xsi:schemaLocation=
"http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd
http://java.sun.com/xml/ns/persistence/orm
http://java.sun.com/xml/ns/persistence/orm_1_0.xsd"
xmlns:orm="http://java.sun.com/xml/ns/persistence/orm"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/persistence">
<persistence-unit name="IALPR" transaction-type="JTA">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>jdbc/jbpm-ds</jta-data-source>
<class>org.drools.persistence.info.SessionInfo</class>
<class>org.jbpm.persistence.processinstance.ProcessInstanceInfo</class>
<class>org.drools.persistence.info.WorkItemInfo</class>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.H2Dialect"/>
<property name="hibernate.max_fetch_depth" value="3"/>
<property name="hibernate.hbm2ddl.auto" value="update"/>
<property name="hibernate.show_sql" value="true"/>
<property name="hibernate.transaction.manager_lookup_class"
value="org.hibernate.transaction.BTMTransactionManagerLookup"/>
</properties>
</persistence-unit>
</persistence>
UPDATE:
To solve this, create a ProcessInstanceInfo.hbm.xml in the META-INF folder, with the following content:
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" > <hibernate-mapping package="org.jbpm.persistence.processinstance">
<!-- access="field" for fields that have no setter methods -->
<class name="ProcessInstanceInfo" table="ProcessInstanceInfo">
<id name="processInstanceId" type="long" column="InstanceId">
<generator class="native" />
</id>
<version name="version" type="integer" unsaved-value="null" access="field">
<column name="OPTLOCK" not-null="false" />
</version>
<property name="processId" access="field" />
<property name="startDate" type="timestamp" access="field" />
<property name="lastReadDate" type="timestamp" access="field" />
<property name="lastModificationDate" type="timestamp" access="field" />
<property name="state" type="integer" not-null="true" access="field" />
<property name="processInstanceByteArray" type="org.hibernate.type.PrimitiveByteArrayBlobType"
column="processInstanceByteArray" access="field" length="2147483647" />
<set name="eventTypes" table="EventTypes" access="field" >
<key column="InstanceId"/>
<element column="element" type="string"/>
</set>
<!-- NOT mapping [processInstance] field because field is transient -->
<!-- NOT mapping [env] field because field is transient -->
</class>
</hibernate-mapping>
If anyone knows a good tutorial on configuring persistence for jBPM5 please do share...this is insane!