I'm running into some problems with a relatively simple task.
Application.cfc
component {
THIS.datasource = "xmdlocaldevdb";
THIS.name = "TESTING"; // MUST BE SAME AS TOP LEVE APP
THIS.ormsettings.cfclocation = "/xmdroot/model/beans";
THIS.environmentName = "TESTING";
THIS.ormenabled = "true";
THIS.ormsettings.cfclocation = "/xmdtestroot/model/beans";
THIS.ormsettings.logSQL = "true";
THIS.ormSettings.dbCreate = "none";
THIS.ormsettings.eventhandling = true;
}
Parent.cfc
component persistent="true" table="Parent" {
property name="id" fieldtype="id" column="ParentID" generator="identity";
property name="Title" type="string";
property
name="Childs"
fieldtype="one-to-many"
cfc="Child"
singularname="Child"
fkcolumn="ChildID";
public void function removeChildren(){
if( !IsNull( this.getChilds() ) ) {
ArrayClear( this.getChilds() );
}
}
}
Child.cfc
component persistent="true" table="Child" {
property name="id" fieldtype="id" column="ChildID" generator="identity";
property
name="Parent"
fieldtype="many-to-one"
cfc="Parent"
fkcolumn="ParentID";
}
create.cfm:
ormReload();
parent = new xmdtestroot.model.beans.Parent();
parent.setTitle('Title One');
child = new xmdtestroot.model.beans.Child();
child.setParent(parent);
parent.addChild(child);
entitySave(parent);
entitySave(child);
modify.cfm:
ormReload();
parent = entityLoad('Parent', 15, true);
parent.setTitle('Title - MOD');
parent.removeChildren();
--------
All pretty straightforward, I think? The create file runs fine, records created in the db correctly. The modify file is throwing:
Column 'ChildID' cannot be null |
I've read in numerous places that this should work. I'm hoping someone can point out my obvious mistake.
As a note, I'm aware that the flushAtRequestEnd flag is left defaulted to true - this is a legacy app that's, unfortunately, unlikely to change in that regard soon...
Thanks,
Jonathan