Calling entityLoadBYPK and init() not being called automatically [Lucee 4.5.1.000 final]

Hi,

I am running into an issue where the init constructor of orm entities does
not appear to be being called automatically when using the entityLoadByPK()
method.

I’ve found a workaround by using the orm event handling postLoad() method
to call the init() constructor but I thought it was called automatically.

Can anyone fill me in on this? Is there some other setting that needs to be
enabled?

I’m running Lucee 4.5.1.000 final.

Many thanks in advance,
Tom

A bit more information:

The reasoning behind me wanting to run the init constructor is to
initialize some defaults on fields that would otherwise be returned as null
values. When a null field is returned from the db I’m having to check for
the existence of the field using the isNull() function.

I’ve used orm extensively on ACF and the constructor gets called before the
object loads from the database.

I tried calling the init() constructor using the preLoad() event.

eg

void function preLoad() {
this.init();
}

However, this does not appear to work.On Sunday, 7 June 2015 11:33:15 UTC+1, Tom Bishop wrote:

Hi,

I am running into an issue where the init constructor of orm entities does
not appear to be being called automatically when using the entityLoadByPK()
method.

I’ve found a workaround by using the orm event handling postLoad() method
to call the init() constructor but I thought it was called automatically.

Can anyone fill me in on this? Is there some other setting that needs to
be enabled?

I’m running Lucee 4.5.1.000 final.

Many thanks in advance,
Tom

Think perhaps my understanding of how the init() function is called was
wrong. Think it actually only gets called on new entities ( ie entityNew()
), not ones loaded from the db using entityLoad().

Answering my own questions here. Sundays are great for talking to oneself.On Sunday, 7 June 2015 11:50:04 UTC+1, Tom Bishop wrote:

A bit more information:

The reasoning behind me wanting to run the init constructor is to
initialize some defaults on fields that would otherwise be returned as null
values. When a null field is returned from the db I’m having to check for
the existence of the field using the isNull() function.

I’ve used orm extensively on ACF and the constructor gets called before
the object loads from the database.

I tried calling the init() constructor using the preLoad() event.

eg

void function preLoad() {
this.init();
}

However, this does not appear to work.

On Sunday, 7 June 2015 11:33:15 UTC+1, Tom Bishop wrote:

Hi,

I am running into an issue where the init constructor of orm entities
does not appear to be being called automatically when using the
entityLoadByPK() method.

I’ve found a workaround by using the orm event handling postLoad() method
to call the init() constructor but I thought it was called automatically.

Can anyone fill me in on this? Is there some other setting that needs to
be enabled?

I’m running Lucee 4.5.1.000 final.

Many thanks in advance,
Tom