cancel
Showing results for 
Search instead for 
Did you mean: 

JPA or JCR to store process related information

xandros
Champ in-the-making
Champ in-the-making
Hi,
I set up Activiti to use my JPA entity to store some of information taken from user during the process execution. All works like a charme. Now at the end of process there is not reference (in history) between process instance and entity stored, then to solve this problem I think is possible to store entity ID as process variable before end of process. This can works, but I lose the history of record change. The problem rise if I store document and want maintain the history of document/entity. With JPA implementation I can reference only the last shot of my records losing his history. What do you think of change JPA for JCR and store the PATH of entity as process variable ?
5 REPLIES 5

frederikherema1
Star Contributor
Star Contributor
You can always create your own VariableType (take a look at JpavariableType etc, and search forum to see how you can plug it in). In this type, you can store any information as a variable, providing you hooks to save/load variables when they are needed using the exact logic you require.

xandros
Champ in-the-making
Champ in-the-making
I look at JPAEntityVariableType and I see in the inital comment like this:

"Variable type capable of storing reference to JPA-entities"

the I use this in my process definition:


<serviceTask id="servicetask1" name="Create User Request" activiti:expression="${requestService.create(initiator)}"
activiti:resultVariable="userRequest"></serviceTask>

where the expression create and return JPA entity

public Request create(String creator){
  logger.info("User " + creator + " create new request.");
  Request entity = new Request();
  entity.setCreator(creator);
  return jpaRequestDao.saveOrUpdate(entity);
}

then at the end of process I have my Entity stored in DB.
I suppose than the reference of my JPA is stored in process variable userRequest.
Where I can see this reference in Activiti Database (for history retrieve)?

Thanks

xandros
Champ in-the-making
Champ in-the-making
Debugging applciation I can see that:

- during process execution the JPA reference is stored in ACT_RU_VARIABLE.
- ended the process the JPA reference is removed from ACT_RU_VARIABLE but is not inserted in ACT_HI_DETAIL as I aspected.

Can you help me to understand please.

xandros
Champ in-the-making
Champ in-the-making
Solved

Setting

<property name="history" value="full" />

Also JPA reference will be stored in history!
Good, hidden but works…

I hope this info can help other users.
Thanks.

ronald_van_kuij
Champ on-the-rise
Champ on-the-rise
this is not only true for jpa references but for all variables. If history != full they will not be preserved after the process ends