cancel
Showing results for 
Search instead for 
Did you mean: 

The best practise to bind JPA-Entity to process

omd
Champ in-the-making
Champ in-the-making
Hi,

I would like to ask you, what is the best way of binding a JPA-Entity to activiti process?
I tried to set bean as a process variable:

variables.put("myBean", myBean);
runtimeService.startProcessInstanceByKey("myProcess", variables);

But this solition has a big drawback. I store the same data in two different places. One is table generated by my entityManager, and second is serialized object variable in activiti DB. The other problem is with querying by fields of my bean, I believe it is so complicated because there is  always need to deserialize a bean before checking values of fields.

Is it possible to store in a process only a reference to my bean ? I could do it by hand by define some map wiring  task id with my bean id.  Maybe there is some mechanism out of box which do this work?

Best Regards.
4 REPLIES 4

omd
Champ in-the-making
Champ in-the-making
Is it a good idea to store in process variables only jpa-entity object id?
<java>
variables.put("myBeanID", myBean.getId());
runtimeService.startProcessInstanceByKey("myProcess", variables);
</java>

Regards

jbarrez
Star Contributor
Star Contributor
> Is it possible to store in a process only a reference to my bean ?

Activiti has out of the box JPA integration, solving exactly this problem: http://activiti.org/userguide/index.html#_jpa

jwestra
Champ in-the-making
Champ in-the-making
Joram,

I'm interested in learning more on Activiti/JPA integration.  Our business entity layer is Cassandra and not JPA-enabled, but understanding the semantics might allow us to replicate similar behavior.

For instance, what classes/methods does Activiti add the hooks to autostore and autoload (e.g. if the process var is annotated as a JPA entity, go load it from the EntityManager when the process variable is loaded)?

Jason
Getting started

Tags


Find what you came for

We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.