[coldbox:26448] [CBORM] Recommendations for how to handle orm post load data formatting and orm events

This really isn’t a ColdBox issue, per se, but more of an ORM event handling question.

The issue sounds like an ORM mapping issue. How are the alerts mapped to the vendor and how are the saves of the alerts being handled within the async interception.

Since these alerts are predicated on a state change to the vendor, I would suggest using the postInsert and postUpdate interception points, instead.

I would also suggest using the PK of the vendor (instead of passing the object) and using the new() or populate() methods for creating the alerts. This ensures that the vendor entity being loaded in the async thread is clean.

HTH,

Jon

True its not strictly a coldbox issue, but the postload interceptor is what starts the problem by applying the formatting and making the object always dirty. It when combined with the async alert interceptor that has to retrieve the vendor object causes the duplication. There is no “real” relationship between alert and vendor because an alert can be tied to a number of different object types. I guess my question is more about what is the recommended design pattern for formatting data after the object is retrieved and stripping it before its saved to the database. Everything I can think of seems to fail in this scenario.

If I have understood the situation correctly … the database should store unformatted numbers but you want to display them in a particular format … then you should have some sort of getPhoneNumberFormatted() method on your class, and not even touch the actual data.