-
Enhancement
-
Resolution: Unresolved
-
Minor
-
None
-
7.45.0.Final
-
None
-
False
-
False
-
NEW
-
NEW
-
Undefined
-
---
-
---
-
Context:
Configuring JPA persistence for process variables
http://mswiderski.blogspot.com/2014/02/jbpm-6-store-your-process-variables.html
https://karinavarela.me/2018/12/22/persisting-custom-process-variables-in-different-db-on-jbpm/
Implementation example:
https://github.com/jbossdemocentral/rhpam7-order-management-demo-repo
Issue:
If you try to bind more than one process variable to a process or if you deploy two projects requiring a JPA persistence you get at runtime a foreign constraint violation error. E.g.
Caused by: org.h2.jdbc.JdbcSQLException: Referential integrity constraint violation: "FK97CT3G3OQBWV7W3FQR12KHWA4: PUBLIC.MAPPEDVARIABLE FOREIGN KEY(MAP_VAR_ID) REFERENCES PUBLIC.TRAVEL(ID) (1)"; SQL statement:
update MappedVariable set MAP_VAR_ID=? where mappedVarId=? [23506-193]
Reason:
The JPA implementation of org.drools.persistence.jpa.marshaller.VariableEntity create a foreign constraints on the table MAPPEDVARIABLE due the one to many relationship
mappedVariables.
Solution:
Add an annotation to avoid the foreign key constraint:
@JoinColumn(name = "MAP_VAR_ID", nullable = true, foreignKey = @ForeignKey(value = ConstraintMode.NO_CONSTRAINT))