How to save business data with an aggregation relationship

1
0
-1

Hello,

I've read the documentation's part and some previous questions but can't really understand, Can anyone help me understanding this topic.

What is meant exactly by "aggregation relation mean that attribute of this type must exist prior to add them", attributes of which object, parent, child or both?

Moreover, if i have a multiple aggregation relationship between parent(requestInfo), child(actionTask). why does the following operation requestInfo setActions script fail with this message "Forbidden instance of com.company.model.actionTask found. It is only possible to reference persisted instances in an aggregation relation"

def List actions=new ArrayList();

def actionToAdd=actionTaskDAO.newInstance(nextInLineEmployeeID,BonitaUsers.getUser(apiAccessor,nextInLineEmployeeID).getTitle(),"",evaluatedComment,activityInstanceId);

actionToAdd.setActionDate(LocalDateTime.now());
actionToAdd.setExecutedByDelegate(false);
if(nextInLineDelegateID){
actionToAdd.setExecutedByDelegate(true);
actionToAdd.setDelegateID(nextInLineDelegateID);
actionToAdd.setDelegateName(BonitaUsers.getUser(apiAccessor, nextInLineDelegateID).getTitle())
}
actions.addAll(requestInfo.getActions());
actions.set(actions.size()-1,actionToAdd );

return actions;

1 answer

1
0
-1

| It is only possible to reference persisted instances in an aggregation relation ?

Yes. It is not possible to create a parent and it's aggregated child in the same transaction. The action you try to add to your requestInfo action list must be created in a separated transaction (=~ separated operation in your activity. You'll need to declare a newAction variable in your process). Is it relevant to have an aggregation in this case ? Can the action be referenced elsewhere in your model ?

HTH

Romain

Notifications