ColdFusion ORM loads a base component and not a derived component?

Let's say we have a base component Request

and sub-classes RequestA

, RequestB

that are associated with the use of tables for each subclass without discriminator.

We always did entityLoadByPk('Request', someSubclassEntityId)

and the method returned a component instance RequestA

or RequestB

.

Somehow, it just stopped behaving this morning and the code hasn't changed at all. The function now entityLoadByPk

returns instances Request

rather than derived components.

To keep the code from changing, we copied the entire application into another ColdFusion window (worked with CF11), and it behaved the same as it did in our CF9 field.

Obviously there must be a setting in the CF9 field or something that has changed, but we've looked at everything we could think of and we just can't find any explanation.

The problem persists even after we rebooted the server and cleared all possible caches we could think of (Template Cache, Component Cache, and also we call ormEvictQueries and ormEvictEntity).

Here's the ORM settings:

<cfset this.ormSettings = {
    dialect = 'MicrosoftSQLServer',
    eventHandling = true,
    flushAtRequestEnd = false,
    logSql = true,
    saveMapping = false,
    cfcLocation = domainModelLocation
}>

      

Here is an example of a mapping (I have stripped the unnecessary relationships):

<!--- IPSRequest.cfc --->
<cfcomponent persistent="true" table="IPSRequest" lazy="no">
    <cfproperty name="id" type="numeric" fieldtype="id" column="id" generator="assigned">

</cfcomponent>

<!--- IPSInfoManFileTracerRequest.cfc --->
<cfcomponent 
    persistent="yes" 
    extends="IPSRequest" 
    table="IPSInfoManFileTracerRequest"
    joincolumn="ips_request_id">

    <!--- The id property was repeated because of a bug --->
    <cfproperty name="id" type="numeric" fieldtype="id" column="ips_request_id" generator="assigned">

</cfcomponent>

      

Here's the generated mappings from field CF9:

<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
                                   "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
    <class entity-name="IPSRequest" lazy="false"
        name="cfc:charities.cts.cfc.model.ips.request.IPSRequest" table="IPSRequest">
        <id name="id" type="int">
            <column length="10" name="id"/>
            <generator class="assigned"/>
        </id>
    </class>
</hibernate-mapping>

<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
                                   "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
    <class entity-name="InfoManFileTracerRequest" lazy="true"
        name="cfc:CHARITIES.CTS.cfc.model.ips.request.InfoManFileTracerRequest" table="IPSInfoManFileTracerRequest">
        <id name="id" type="int">
            <column length="10" name="ips_request_id"/>
            <generator class="assigned"/>
        </id>
    </class>
</hibernate-mapping>

      

Here's the mappings generated in the CF11 field with the same code:

<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
                                   "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
    <class entity-name="IPSRequest" lazy="false"
        name="cfc:charities.cts.cfc.model.ips.request.IPSRequest" table="IPSRequest">
        <id name="id" type="int">
            <column length="10" name="id"/>
            <generator class="assigned"/>
        </id>
    </class>
</hibernate-mapping>

<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
                                   "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
    <joined-subclass entity-name="InfoManFileTracerRequest"
        extends="cfc:charities.cts.cfc.model.ips.request.IPSRequest"
        lazy="true"
        name="cfc:charities.CTS.cfc.model.ips.request.InfoManFileTracerRequest" table="IPSInfoManFileTracerRequest">
        <key column="ips_request_id"/>
    </joined-subclass>
</hibernate-mapping>

      

We can see that the mappings seem to be wrong in field CF9, but it worked fine with the same code.

The last fix applied to the CF9 box was hf902-00007.jar

and was done in 2014.

I have to say that I am puzzled and have no idea what would change the behavior?

EDIT:

We updated the CF9 field to CF11 and the problem went away even though we used the migration tool to import the configuration settings.

We're glad this fixed the issue, but we're very concerned that you don't know what influenced the behavior and to understand how fragile ColdFusion can be.

Our production box is still running on CF9 at the moment ...

+3


source to share





All Articles