Re: Persist Data in jbpm case mgmt process

57 views
Skip to first unread message

Abhijit Humbe

unread,
Jan 25, 2021, 8:09:29 AM1/25/21
to dianal...@gmail.com, jBPM Usage
In place of ScriptTask try using HumanTask.Earlier I do encounter similar issue while using scriptTask in case.
Abhijit Humbe


On Fri, Jan 22, 2021 at 5:18 AM dianal...@gmail.com <dianal...@gmail.com> wrote:
A little more details - I can print the case file variable, it is just not in the "working memory". Does anyone know how to make the case file variables into working memory? 

On Thursday, January 21, 2021 at 5:33:18 PM UTC-6 dianal...@gmail.com wrote:
Hi, 

I've followed these links and setup the Persistent Unit for my case project. I can see that my tables are created in sql, but after I inserted case data into the case and the case has completed, the data was never inserted into the sql table. 


Here is my case process: pretty much just a start, a print task, and an end. I have confirmed that the case data (cardApp) has been inserted correctly, but it is not persisted into the table. 

Can someone help me understand what I did wrong? 

Thank you!!!Capture.PNG





--
You received this message because you are subscribed to the Google Groups "jBPM Usage" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jbpm-usage+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jbpm-usage/4a1ff509-0098-417a-a93d-280661301981n%40googlegroups.com.

dianal...@gmail.com

unread,
Jan 25, 2021, 1:13:08 PM1/25/21
to jBPM Usage
Hi Abhijit, 

Really appreciate your response. I've tried to replace the script task with the human task but with no luck. Please see below for my current process and my project attached. FirstCheck stage is looking for a CardApplication object, then it auto completes.

I have a case project created with Data object (CardApplication), and a case definition called "MainProcess". 
Here are my steps:
1. Configured data persistent for case mgmt as per (https://dzone.com/articles/persist-case-files-in-different-database-table-alo)
2. Deploy the project from BC (7.32.0.FINAL) to kie server. 
3. Starts a case via rest endpoint: curl -X POST "http://domain/kie-server/services/rest/server/containers/acq_1.0.0-SNAPSHOT/cases/ACQ.MainProcess/instances" -H "accept: application/json" -H "content-type: application/json" -d "{}"
4. Add cardApp data into caseFile via rest endpoint: http:// domain/kie-server/services/rest/server/containers/acq/cases/instances/CASE-0000000005/caseFile/cardApp
{
    "com.card.acq.CardApplication": {
        "dob": "00-00-0000",
        "email": "123...@gmail.com",
        "firstName": "John",
        "lastName": "Doe",
        "middleName": "",
        "phone": "0987654321",
        "ssn": "000-00-0000",
        "ipAddress":"0.0.0.0"
    }
}
5. I can see a record inserted into VariableInstanceLog AND CaseFileDataLog, but there is no records inserted into CardApplication. 

Capture11.PNG

ACQ.zip

Amit ninja

unread,
Jan 26, 2021, 12:12:21 AM1/26/21
to dianal...@gmail.com, jBPM Usage
I have imported the project and saw that you are still using the script task instead of human task.

Can you please attach the dependency(jar file)com.ven:ekataapi:1.0.0-SNAPSHOT  to replicate this at out end ?

dianal...@gmail.com

unread,
Jan 26, 2021, 1:12:42 AM1/26/21
to jBPM Usage
Hi Abhijit, 

I have removed both the human task and the script task in my case definition (MainProcess file) and now I only have a stage and and end node. 
I have also removed the jar dependency to remove any confusion as attached. 

Thank you so much for looking into this. 

Thanks, 

Diana 
ACQ.zip

Abhijit Humbe

unread,
Jan 26, 2021, 11:13:51 AM1/26/21
to dianal...@gmail.com, jBPM Usage
Try setting hibernate.id.new_generator_mappings=true in persistence.xml file and see if it works.
Abhijit Humbe


dianal...@gmail.com

unread,
Jan 26, 2021, 12:48:59 PM1/26/21
to jBPM Usage
Hi Abhijit, 

Thank you for your response. 

My main requirement is to be able to use the case definition, and persist caseFile data and  MappedVariable throughout the whole case process. 

After setting  hibernate.id.new_generator_mappings=true, I am still unable to insert records into my table, and the logs shows nothing from hibernate even when I have the hibernate.show_sql = true. 

Some observations:
1. If I create the flow as "case definition", then the records are not inserted into the table, no logs are shown from the server for hibernate. The record is being inserted into both CaseFileDataLog and ProcessInstanceLog properly. 

2. If I create the flow as a "business process", then I am able to insert the records into the table with the below logs. However, nothing gets inserted into the MappedVariable table. The record is being inserted into ProcessInstanceLog properly.

17:32:05,281 INFO  [stdout] (default task-6) Hibernate: select next_val as id_val from CARDAPPLICATION_ID_SEQ with (updlock, rowlock)
17:32:05,284 INFO  [stdout] (default task-6) Hibernate: update CARDAPPLICATION_ID_SEQ set next_val= ? where next_val=?
17:32:05,288 INFO  [stdout] (default task-6) Hibernate: select next_val as id_val from CARDAPPLICATIONADDRESS_ID_SEQ with (updlock, rowlock)
17:32:05,327 INFO  [stdout] (default task-6) Hibernate: update CARDAPPLICATIONADDRESS_ID_SEQ set next_val= ? where next_val=?
17:32:05,333 INFO  [stdout] (default task-6) Hibernate: insert into dbo.CardApplication (DOB, Email, First_Name, Ip_Address, Last_Name, Middle_Name, Phone, SSN, Card_Application_Key) values (?, ?, ?, ?, ?, ?, ?, ?, ?)
17:32:05,336 INFO  [stdout] (default task-6) Hibernate: insert into CardApplicationAddress (Address, Address_Type, Card_Application_Key, City, State, Zipcode, Card_Application_Address_Key) values (?, ?, ?, ?, ?, ?, ?)
 

I am using 7.32.0.FINAL version of jbpm. Am I using the right version for this functionality? 

Thanks, 

Diana 

Abhijit Humbe

unread,
Jan 26, 2021, 1:13:19 PM1/26/21
to dianal...@gmail.com, jBPM Usage
Hi Diana,
Yes, this functionality should work with 7.32 release. Give me some time to try with a provided project, will update you shortly.
Abhijit Humbe


Amit ninja

unread,
Jan 27, 2021, 3:17:38 AM1/27/21
to Abhijit Humbe, dianal...@gmail.com, jBPM Usage
I can see you are using marshalling strategy as below:
~~~~~~~~~~
org.drools.persistence.jpa.marshaller.JPAPlaceholderResolverStrategy("CARDACQPersistenceUnit", classLoader)

~~~~~~~~~~

Please try to add the below one:

~~~~~~~~~~~~
org.jbpm.casemgmt.impl.marshalling.CaseMarshallerFactory.builder(classLoader).withDoc().withJpa("CARDACQPersistenceUnit").get();

~~~~~~~~~~

I have done changes in your configuration and can see the below entries in cardapplication table.

~~~~~~~~~~~

 select * from cardapplication;
 card_application_key |    dob     |       email       | first_name | ip_address | last_name | middle_name |   phone    |     ssn    
----------------------+------------+-------------------+------------+------------+-----------+-------------+------------+-------------
                    1 | 00-00-0000 | 123...@gmail.com | John       | 0.0.0.0    | Doe       |             | 0987654321 | 000-00-0000

~~~~~~~~

I have attached the modified project , please make the changes in settings----->Persistence like 
once you import the project , build and deploy it and run teh below curl command , change the user name , password, container id and so on.

~~~~~~~~

curl -X POST -u 'amit:amit' "http://localhost:8080/kie-server/services/rest/server/containers/acq_1.0.4-SNAPSHOT/cases/ACQ.abc/instances" -H "accept: application/json" -H "content-type: application/json" -d "{ \"case-data\": { \"cardApp\": { \"com.card.acq.CardApplication\": { \"dob\": \"00-00-0000\", \"email\": \"123...@gmail.com\", \"firstName\": \"John\", \"lastName\": \"Doe\", \"middleName\": \"\", \"phone\": \"0987654321\", \"ssn\": \"000-00-0000\", \"ipAddress\":\"0.0.0.0\" } } }, \"case-user-assignments\": {}, \"case-group-assignments\": {}, \"case-data-restrictions\": {}}"


~~~~~~~~

After hitting the above curl command, check the table cardapplication in the database and you will get the entries.


ACQ.tar.gz

dianal...@gmail.com

unread,
Jan 27, 2021, 5:37:43 PM1/27/21
to jBPM Usage
Hi Amit, 

Thank you very much for your resolution. I am able to see records going into CardApplication table. One more question - I don't see records added to the MappedVariable table even though I have extends the org.drools.persistence.jpa.marshaller.VariableEntity in my CardApplication class according to this tutorial: https://dzone.com/articles/persist-case-files-in-different-database-table-alo

Could you please help me understand the gaps here? Thanks again. 

Diana 

Amit ninja

unread,
Jan 27, 2021, 10:59:36 PM1/27/21
to dianal...@gmail.com, jBPM Usage
>- I don't see records added to the MappedVariable table

>>You need to have UserTask in case definition if you want to see records in the MappedVariable table.

,MappedVariable table) is not populated only when there is a script task in case definition

Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted

dianal...@gmail.com

unread,
Jan 28, 2021, 12:56:43 PM1/28/21
to jBPM Usage
Hi Amit, 

Thank you for responding. I've made a few adjustments to remove all script tasks and add a user task to the case definition to insert caseApp (CardApplication). But still no luck getting it inserted into the MappedVariableTable...

When I complete the user task I can see below in the log, but the insert statement only occurred for CardApplication table, not the mappedVariable table.

17:25:31,659 INFO  [stdout] (default task-75) Starting Auth/KYC Check Stage...
17:25:31,694 INFO  [stdout] (default task-75) Hibernate: insert into dbo.CardApplication (DOB, Email, First_Name, Ip_Address, Last_Name, Middle_Name, Phone, SSN) values (?, ?, ?, ?, ?, ?, ?, ?)
17:25:38,387 INFO  [stdout] (default task-77) Hibernate: select cardapplic0_.Card_Application_Key as Card_App1_0_0_, cardapplic0_.DOB as DOB2_0_0_, cardapplic0_.Email as Email3_0_0_, cardapplic0_.First_Name as First_Na4_0_0_, cardapplic0_.Ip_Address as Ip_Addre5_0_0_, cardapplic0_.Last_Name as Last_Nam6_0_0_, cardapplic0_.Middle_Name as Middle_N7_0_0_, cardapplic0_.Phone as Phone8_0_0_, cardapplic0_.SSN as SSN9_0_0_, mappedvari1_.MAP_VAR_ID as MAP_VAR_8_2_1_, mappedvari1_.mappedVarId as mappedVa1_2_1_, mappedvari1_.mappedVarId as mappedVa1_2_2_, mappedvari1_.processInstanceId as processI2_2_2_, mappedvari1_.taskId as taskId3_2_2_, mappedvari1_.variableId as variable4_2_2_, mappedvari1_.variableType as variable5_2_2_, mappedvari1_.OPTLOCK as OPTLOCK6_2_2_, mappedvari1_.workItemId as workItem7_2_2_ from dbo.CardApplication cardapplic0_ left outer join MappedVariable mappedvari1_ on cardapplic0_.Card_Application_Key=mappedvari1_.MAP_VAR_ID where cardapplic0_.Card_Application_Key=?


Please see attached for the updated workspace and the dependency jar. The case definition file is called MainProcess. 


ACQ.zip

Amit ninja

unread,
Feb 2, 2021, 1:25:31 AM2/2/21
to dianal...@gmail.com, jBPM Usage
Are you still can not see entries on mappedVariable  table?

--
You received this message because you are subscribed to the Google Groups "jBPM Usage" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jbpm-usage+...@googlegroups.com.

Diana Liang

unread,
Feb 2, 2021, 8:08:22 AM2/2/21
to Amit ninja, jBPM Usage
Yes I still can’t... 

On Feb 2, 2021, at 12:25 AM, Amit ninja <amitni...@gmail.com> wrote:


Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted

dianal...@gmail.com

unread,
Feb 2, 2021, 5:01:04 PM2/2/21
to jBPM Usage
Hi Amit, 

I still cannot insert data into mappedVariable table. I've changed my case so that the caseFile data is inserted via a user task. (Please see mainProcess case def.) After the change, CaseFileDataLog table stopped logging any entries... 

I've also noticed that in the VariableInstanceLog table, my caseFile variables' names are changed as below. (the number prefix were added somehow) Is this normal? 

Capture123.PNG

I've attached my project and dependency jar here to show you what I'm talking about. Thank you again for your help. 

Diana 

ACQ.zip
Message has been deleted
Message has been deleted

dianal...@gmail.com

unread,
Feb 2, 2021, 5:04:11 PM2/2/21
to jBPM Usage
Google does not allow me to attach my jar here... Please remove it as it is not related to the persistence testing... 

dianal...@gmail.com

unread,
Feb 4, 2021, 9:46:04 AM2/4/21
to jBPM Usage
Hi Amit, 

I am still unable to add data into mapped variable table... Please kindly help...

Reply all
Reply to author
Forward
0 new messages