context instanceof ProcessMarshallerWriteContex protected void addMapping(Object entityId, String entityType, Object entity, ObjectOutputStream context, EntityManager em) {
if (!(entityId instanceof Number) || !(entity instanceof VariableEntity)) {
return;
}
Long processInstanceId = null;
Long taskId = null;
Long workItemId = null;
java.lang.Integer state = null;
if (context instanceof MarshallerWriteContext) {
KieSession ksession = (KieSession)((MarshallerWriteContext)context).wm;
Collection<ProcessInstance> instances = ksession.getProcessInstances();
if (instances.isEmpty()) {
return;
}
ProcessInstance instance = instances.iterator().next();
processInstanceId = instance.getId();
state = instance.getState();
} else if (context instanceof ProcessMarshallerWriteContext) {
ProcessMarshallerWriteContext processContext = (ProcessMarshallerWriteContext) context;
processInstanceId = processContext.getProcessInstanceId();
state = processContext.getState();
taskId = processContext.getTaskId();
workItemId = processContext.getWorkItemId();
} else {
return;
}
VariableEntity variableEntity = (VariableEntity) entity;
MappedVariable mappedVariable = new MappedVariable(((Number)entityId).longValue(), entityType, processInstanceId, taskId, workItemId);
if (state == ProcessInstance.STATE_ACTIVE) {
variableEntity.addMappedVariables(mappedVariable);
} else {
MappedVariable toBeRemoved = variableEntity.findMappedVariables(mappedVariable);
if (toBeRemoved != null) {
toBeRemoved = em.find(MappedVariable.class, toBeRemoved.getMappedVarId());
em.remove(toBeRemoved);
variableEntity.removeMappedVariables(toBeRemoved);
}
}
}On 21 Nov 2018, at 03:41, Motamedi <mota...@urdeveloper.com> wrote:Attached the modified JPAPlaceholderResolverStrategy just in case.
On Tuesday, 20 November 2018 11:53:53 UTC-7, Motamedi wrote:Hi Maciej,I'm trying to setup JPA for a Case Management project using JBPM 7.13.0.Final.I have an entity extending VariableEntity which is used as a case file variable. The deployment is successful and JPA/Hibernate creates the model table in database as well as MAPPEDVARIABLE table.When I update the case through REST API, my model table gets populated but no record inserted into MAPPEDVARIABLE table.Turns out org.drools.persistence.jpa.marshallerJPAPlaceholderResolverStrategy skips adding the records to MAPPEDVARIBALE.Did some debugging, found out the following condition in addMapping is always false because context is instance of MarshallerWriteContext not ProcessMarshallerWriteContext so it never get passed that point.context instanceof ProcessMarshallerWriteContex
So my question is: is that an expected behavior?
I also tried to find a workaround by changing the code to something like following which fixed the issue (MAPPEDVARIBALE table gets populated as expected) but I wasn't if that's a right approach or the root cause is something else:
--
You received this message because you are subscribed to the Google Groups "jBPM Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jbpm-developme...@googlegroups.com.
To post to this group, send email to jbpm-dev...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jbpm-development/0d08e6ea-83c7-4fc7-8d9b-9f08bb3341f9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
<JPAPlaceholderResolverStrategy.java>
Maciej
To unsubscribe from this group and stop receiving emails from it, send an email to jbpm-development+unsub...@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to jbpm-developme...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jbpm-development/6e0bc4a3-5dbd-4e28-b312-3e724de632ff%40googlegroups.com.