When ormSettings in Application.cfc has:
flushAtRequestEnd = true,
autoManageSession = true
Then when making any changes in the admin on Railo (update, new post, change layout, etc) it won’t persist the changes, they are lost after submit.
Changing both of these values to false fixes that issue, but is dangerous because of the custom transaction handling.
I decided to simply do the following:
1.) Create an ORMEventHandler.cfc in my model folder that extends the default orm even thandler
2.) Add a postSave() method to the event handler that runs ormFlush()
3.) Set the eventhandler = “model.ORMEventHandler” in my Application.cfc
Now, this almost works, except… the BaseORMService.cfc does this statically:
// Create the service ORM Event Handler composition
ORMEventHandler = new coldbox.system.orm.hibernate.EventHandler();
So, all of our services, like SettingService use a generic EventHandler, not the one we set up in Application.cfc for eventhandler.
The options are… to make each service’s constructor do:
ORMEventHandler = createObject(“model.ORMEventHandler”);
Which will override the generic one from the extended BaseORMService. This works, but you have to do it in the constructor for every model…
I think that what needs to be done is that the BaseORMService.cfc needs to check to see if an eventhandler has been set for ormsettings, and then set that as the ORMEventHandler instead of the generic one.
Does this sound right? Does anyone know how to access the properties from ormsettings in Application.cfc from the BaseORMService?