AuditTrail and associations to AuditTrail.log

Hello Mendix Community: I am trying to use the latest version of AuditTrail (version 3.2) in Business Modeler 5.16.1 As described in the documentation, I am using the "Association and events" rather than the "Inheritance" approach. Those instructions are: Association & events Add a reference set association from your entity to the 'AuditTrail.Log' entity or an association from the 'AuditTrail.Log' entity to the entity that needs to be audited. Add en After Create, Before Commit and Before Delete event to your entity identical to the events on the AudittrailSuperClass. The Java actions will automatically create the log item and all required loglines based on the changes Configure the constant: 'LogOnlyChangedAttributes' whether or not you want to log all attributes or just the changes Add the 'AuditTrailOverview' form to your navigation. In particular, I've created an association from the "AuditTrail.Log" entity to the entity that needs to be audited ... which is in my case named "LabOps.Record". When I try to run my application, I frequently see console errors for Log Node Audit Trail that say: "Could not find association in audit trail super class: LabOps.Record." and the first line of the stack trace says: "java.lang.IllegalArgumentException: The given member name 'AuditTrail.Log_Record' has no corresponding member in this object of type 'LabOps.Record'" So, I check the domain model and there is an association from AuditTrail.Log that points to LabOps.Record (at least I see the appropriate box and arrow). When I look at the associations in AuditTrail.Log I see the expected entry with name: Log_Record, type: Reference, owner: Default, parent: AuditTrail.Log, child: LabOps.Record. However, when I look at the associations in LabOps.Record there is no entry named Log_Record. In other words, the association is only listed in the parent, but not in the child. Every other association that I have created (I think) has had an association entry in both the parent entity and in the child entity. So, my question is: Did I misconfigure or misunderstand how to create the Log_Record association? Is this a problem with the AuditTrail module when trying to create an association from the AuditTrail domain model to a different domain model? Is this something that is not being handled automatically by the combination of Business Modeler 5.16.1 and AuditTrail 3.2? Thanks for your consideration, John
2 answers

I think you need a reference set (* - *), and in one of my apps where the AuditTrail module is functioning as expected, my Log entity is the "child". The association is thus visible from the entity I want to log and not visible in the properties of the Log entity.

Hope that helps!



Thanks for your input. I must confess that I always get confused in terms of knowing when I need to use reference set (* - *) as opposed to reference (1 - *). My thinking was that each element of the entity to be logged would have multiple entries in the log table but that each of entries in the log table would point to only one element of the entity to be logged. However, based on your recommendation, I will try to convert to a reference set.

However, the more that I look at it, the more that I think I either don't understand how an association (either 1-* or -) that crosses modules differs from an association between two entities in the same module. Shouldn't they look and behave the same if they seem to be identical in terms of direction of the arrow and 1-* or -?

Here is an example: I'm going to create two entities to be logged: one called EntityInAuditTrail that lives in the AuditTrail module and one called EntityInLabOps that lives in the LabOps module.

Next I create an association from AuditTrail.Log to AuditTrail.EntityInAuditTrail and one from AuditTrail.Log to LabOps.EntityInLabOps.

Finally, I check the association properties of all three entities:

Here are the association properties of AuditTrial.Log that shows both the LogEntityInAuditTrail and LogEntityInLabOps associations:

alt text

Here are the association properties of AuditTrail.EntityInAuditTrail that shows the Log_EntityInAuditTrail association:

alt text

But here are the association properties of LabOps.EntityInLabOps that doesn't show the Log_EntityInLabOps:

alt text

Shouldn't an association of any type show up in both of the entities ... even if those entities are in different modules? Even if I change these to ReferenceSets rather than References, I see no entry in the association properties of LabOps.EntityInLabOps. Is this a problem with cross-module associatins in BusinessModeler 5.16.1 .... or am I utterly clueless as to what I should expect to see?

Thanks for your consideration,