Since nobody answered my question correctly, or didnt get an answer at all in previous questions, i will write down the answer in case someone would have the same issue.
The main problem is that the Bonita really likes to run jobs in parallel. To solve this problem you need to understand how hirbernate/spring works.
First of all the reason this error appears:
It doesnt have to do anything with composition/aggregation setting, the reason is the eager (alway load)/ lazy (only load when needed) is set to eager, in this case hibernate versions all objects under the currently saved object that has eager loading. This can be manipulated in the entity class, however, in Bonita you dont have the option for that.
This is the annotation for the lazy setting with aggregation:
@ManyToOne(optional = true, fetch = FetchType.LAZY, cascade = CascadeType.MERGE)
And this is the the annotation generated by Bonita if you have an eager with composition:
@OneToMany(orphanRemoval = true, fetch = FetchType.EAGER, cascade = CascadeType.ALL)
To be honest i didnt check what will be generated, if i changed the aggregation to composition, because it is a given in the structure, the only thing that i can change without re planning the whole structure is the eager/lazy setting.
In this annotation, the CascadeType setting is that is responsible for my problem. If ALL is set, then all child objects will be versioned if you save the parent.
When i had my problems, i had objects with aggregation set with eager, it was convenient to use in the front end, but it caused the error mentioned in the question
To avoid this error, you should always use lazy loading (only load objects when needed), otherwise you might get this error.
I tested this and could reproduce this error, by starting to task parallel with two different parent objects with the same child object, and if i used eager i got the error, and the child got versioned, if i used lazy loading, then everything worked fine.
To sum it up:
Error cause: Eager/Lazy setting in Bonita, with eager the CascadeType is set to ALL, and will version child objects which will cause transient exception in parallel use of the parent object.
To solve this: Use Lazy loading (only load when needed in bdm setting), and for the front end you might need to create an API extension.
Edit: With composition setting this could be avoided, since one child will belong only to one parent, and another parent cant have this object, so even with eager, it will work fine as long as you use composition. However if you use aggregation then is it is almost necessary to use lazy (only load when needed setting).
Regards
Zoltan