cancel
Showing results for 
Search instead for 
Did you mean: 

Activiti persistence

stroobat
Champ in-the-making
Champ in-the-making
When starting workflows (or subflows) you can pass objects as parameters to the workflow.
When passing an object, the object will be stored as a bytearray in the activiti tables.

Is it still needed that I write my own persistence layer (hibernate, jpa, mybatis, …) or can I trust activiti to persist my bussines objects ?

Suppose that I start a worflow with order information, so in stead of creating an ORDER table and write the sql to store the data, I let activiti store
the data in the activiti tables.

I'm aware that the objects are removed when the flow finishes. And I'm also aware that you cannot use regular SQL to consult the data.

Best regards,

T.
5 REPLIES 5

mhdshahdoost
Champ in-the-making
Champ in-the-making
save your business data on separated tables.for example maybe you need to delete [clean] data on Activiti databases for some reason [upgrade]

and your business data is lost.

paradigma
Champ in-the-making
Champ in-the-making
Regarding this question, can I request the opinion of a member of the Activiti development team? In fact I think that the use of native Activiti persistence mechanism can be a big advantage in some cases.

ronald_van_kuij
Champ on-the-rise
Champ on-the-rise
An advantage in some cases, but a real serious domain model, use separate tables and just store some small parts in activiti, or just references.

frederikherema1
Star Contributor
Star Contributor
Ronald is as good as a member of the development team Smiley Wink

Activiti has some basic support for JPA-integration. It's basically a custom "variable type" that allows you to store JPA-entities. Instead of storing the actual serialized Java-object, we store a the class-name and the ID. Next time the variable is required (e.g.. in a getVariables() call), the variable is fetched from the configured entityManager and returned. The JPA-entity will be returned as a process-variable value and the storage is transparent to the consumer of the API.

If you have another way of fetching entities (eg. your own OrderService.getOrderById()), you can create a VariableType that does that call when a variable of that type is needed. When storing the variable in activiti, you can store the ID in the valueFields (which is provided in the VariableType) to use when fetching it later. This approach allows you to seamlessly use business-object, stored in separate tables which don't get deleted by activiti.

The above was a short description, take a look at the org.activiti.engine.impl.variable.JPAEntityVariableType and org.activiti.engine.impl.variable.EntityManagerSession implementations for dirty details.

ronald_van_kuij
Champ on-the-rise
Champ on-the-rise
But I have/take less time to write a better response 😉