Jonathan Price
unread,Apr 18, 2015, 1:28:00 AM4/18/15Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to cf-or...@googlegroups.com
We keep audit records for some DB tables in our system, and I'm running into an ID problem with postInsert. I'm new with these handlers, and really would appreciate any critique of the procedure. Goes something like
component persistent="true" table="Object1" {
property name="id" fieldtype="id" column = "Object1ID" generator="identity";
property name="Field1" type="string";
public void function postInsert() {
var history = EntityNew('Object1History');
history.setField1(this.getField1());
history.setObject1(this);
}
}
component persistent="true" table="Object1History" {
property name="id" fieldtype="id" column = "Object1HistoryID" generator="identity";
property name="Field1" type="string";
property name="Object1" fieldtype="many-to-one cfc="Object1" fkcolumn="Object1ID";
}
And the update code is something like:
local.obj = EntityNew("Object1");
local.obj.setField1('something here');
EntitySave(local.obj);
And I'm getting an error about Object1ID not being allowed a null value, presumable because of the 'history.setObject1(this)' bit.
My questions are 1) Can I even do this? and 2) Is anyone else doing something similar? it's seems like these even handlers are ready made for this stuff.