ormcoldfusioncfmlcoldfusion-2018

Coldfusion EntityLoad reading calculated field


I have an Entity with a lot of fields.

<cfscript>
component persistent="true" output="false" {
...
property name="placeholder"     default = 0;
property name="expired"         update=false    insert=false;
property name="admin"           default = 0;
property name="partner"         default = 0;

Much later, but in the same request. I am going to do this

if (!arguments.Account.getPlaceholder() )   local.arRoles.append("account");
if (!arguments.Account.getExpired()     )   local.arRoles.append("event");
if (arguments.Account.getAdmin()        )   local.arRoles.append("admin");
if (arguments.Account.getPartner()      )   local.arRoles.append("partner");

And I get an error that looks like this

enter image description here

I do a dump of the object. It looks like it should be OK

enter image description here


Solution

  • Expired is not like the other fields. It is backed by a calculation done on the database. That is why it is

     property name="expired"            update=false    insert=false;
    

    Furthermore

     Account = EntityLoadByPK("Accounts", arguments.id);
    

    Many not have what is expected. A read from the DB must be forced

     Account = EntityLoadByPK("Accounts", arguments.id);
     EntityReload(Account);