Let’s say I have two entities, a House:
component
{
property name="Owner" cfc="Owner" fieldtype="many-to-one";
}
And an Owner:
component
{
property name="Name";
}
A House may have an Owner, but doesn’t need to. I have a House associated with an Owner, but now I want to remove the association. I’ve tried the following code:
var house = entityLoadByPK("House", 13);
house.setOwner('');
entitySave(house);
But I get an exception saying that '' cannot be converted to an id, which makes sense. However, although ColdFusion has a concept of null/undefined, it looks like you can’t actually create a null value, only check for them. How would I remove the association in this case?
If you have your relationship defined correctly then I believe what you are looking for is: