Prevent creation of an object using BCO_ or java listener
I need to disable ReferenceLogLine objects of the AuditTrail marketplace module and I don’t want to modify the module. Instead I want to register a java listener that prevents the commits of these objects. I tried to create a BCO_ on ReferenceLogLine and delete the object before it’s committed and I also tried Core.getListenersRegistry().registerBeforeCommitListener() and delete the object there. In both cases the traces show that deleting an object whose .isNew() returns true still causes SQL DELETE and afterwards SQL INSERT is performed despite it’s deleted. And I tried to register ActionListener for mendix internal CommitAction and call addReplaceEvent() to suppress it. However, CommitAction.class is inaccessible from custom code and a replacement java action requires a constructor accepting Scala immutable list which is also inaccessible.
registerBeforeCommitListener is registering a void function so you can not return false. Deleting the copies of the objects here won’t work as you found out.
Not changing a Marketplace module is a good design principle, but if your solution becomes too complex that price is too high.
A procedure to update and patch a module can be a good alternative.