| Philippe, I have a fix for this already but I have been going over this with other scenarios to make sure there are not any other mapping combinations or orders of operations that could lead to similar cases. Thus far my research has concluded that the simple case you outlined (persist followed by a merge within the same transaction on the same entity) is the only one which leads to this obscure modified flag field problem. The fix as I see it is to address the merging of the AddWorkUnit with a ModWorkUnit during the dispatch phase of the Envers AuditProcess. Presently it discards any modified flags values from the original AddWorkUnit (aka persist operation) and uses only those found in the ModWorkUnit (aka merge operation), which aligns with your observation. The solution seems to be to take all modified flag settings which are true from the persist and default those over the modified flag settings from the merge operation. |