[coldbox-3.8.1] update from 3.5.3 + new method

properties struct has a key with an array of entities. the entities are a collection (many-to-many) for this entity that is created.

this passed on 3.5.3:

group.addElement(getBuilderBuildElementService().new(properties=properties).save());

it fails on 3.8.1.

For component having composite key, a map must be specified for the primary key.
The specified object is not the primary key for the component.
[{RAW_TRACE={ at cfBeanPopulator2ecfc1526488154$funcPOPULATEFROMSTRUCT.runFunction(C:\inetpub\domain\Frameworks\coldbox_3_8_1\system\core\dynamic\BeanPopulator.cfc:346)},ID={CF_CFPAGE},TEMPLATE={C:\inetpub\domain\Frameworks\coldbox_3_8_1\system\core\dynamic\BeanPopulator.cfc},LINE={346},TYPE={CFML},COLUMN={0}}, {RAW_TRACE={ at cfBaseORMService2ecfc1361009865$funcPOPULATE.runFunction(C:\inetpub\domain\Frameworks\coldbox_3_8_1\system\orm\hibernate\BaseORMService.cfc:378)},ID={CF_TEMPLATEPROXY},TEMPLATE={C:\inetpub\domain\Frameworks\coldbox_3_8_1\system\orm\hibernate\BaseORMService.cfc},LINE={378},TYPE={CFML},COLUMN={0}}, {RAW_TRACE={ at cfBaseORMService2ecfc1361009865$funcNEW.runFunction(C:\inetpub\domain\Frameworks\coldbox_3_8_1\system\orm\hibernate\BaseORMService.cfc:348)},ID={CF_UDFMETHOD},TEMPLATE={C:\inetpub\domain\Frameworks\coldbox_3_8_1\system\orm\hibernate\BaseORMService.cfc},LINE={348},TYPE={CFML},COLUMN={0}}, {RAW_TRACE={ at cfVirtualEntityService2ecfc1800947949$funcNEW.runFunction(C:\inetpub\domain\Frameworks\coldbox_3_8_1\system\orm\hibernate\VirtualEntityService.cfc:114)},ID={CF_SUPERSCOPE},TEMPLATE={C:\inetpub\domain\Frameworks\coldbox_3_8_1\system\orm\hibernate\VirtualEntityService.cfc},LINE={114},TYPE={CFML},COLUMN={0}}, {RAW_TRACE={ at cfbuild2ecfc308260496$funcSAVE.runFunction(C:\inetpub\domain\ModulesV2\Case\handlers\builder\build.cfc:269)},ID={CF_TEMPLATEPROXY},TEMPLATE={C:\inetpub\domain\ModulesV2\Case\handlers\builder\build.cfc},LINE={269},TYPE={CFML},COLUMN={0}}, {RAW_TRACE={ at cfController2ecfc137642762$funcINVOKER.runFunction(C:\inetpub\domain\Frameworks\coldbox_3_8_1\system\web\Controller.cfc:764)},ID={CFINVOKE},TEMPLATE={C:\inetpub\domain\Frameworks\coldbox_3_8_1\system\web\Controller.cfc},LINE={764},TYPE={CFML},COLUMN={0}}, {RAW_TRACE={ at cfController2ecfc137642762$funcRUNEVENT.runFunction(C:\inetpub\domain\Frameworks\coldbox_3_8_1\system\web\Controller.cfc:648)},ID={CF_UDFMETHOD},TEMPLATE={C:\inetpub\domain\Frameworks\coldbox_3_8_1\system\web\Controller.cfc},LINE={648},TYPE={CFML},COLUMN={0}}, {RAW_TRACE={ at cfColdbox2ecfc1371214042$funcPROCESSCOLDBOXREQUEST.runFunction(C:\inetpub\domain\Frameworks\coldbox_3_8_1\system\Coldbox.cfc:236)},ID={CF_TEMPLATEPROXY},TEMPLATE={C:\inetpub\domain\Frameworks\coldbox_3_8_1\system\Coldbox.cfc},LINE={236},TYPE={CFML},COLUMN={0}}, {RAW_TRACE={ at cfApplication2ecfc922651439$funcONREQUESTSTART.runFunction(C:\inetpub\domain\Applications\Client Tools V2\Application.cfc:130)},ID={CF_UDFMETHOD},TEMPLATE={C:\inetpub\domain\Applications\Client Tools V2\Application.cfc},LINE={130},TYPE={CFML},COLUMN={0}}]

line 346 in beanPopulator.cfc.

if( relType==“array” ) {
// add composed relationship to array
arrayAppend( manyMap, EntityLoadByPK( targetEntityName, relValue ) );
}

it sees that property member (my array of entities) is an array and attempts to EntityLoadByPK on each item.

i guess the problem is those array items are entities and not an array of keys.

can i not pass in a property of entities? can it only accept an array of PK ID’s?

passed in an array of ID’s and everything worked as it should. will have to change the rest of the codebase.

question… i have a relationship property name of valueID in an entity. i pass in a property named valueID when i create an entity, if i see composeRelationships=true, that will use valueID as a PK ID and fetch the entity?

Hi Aaron–

I believe the original issue you experienced should only be an issue if composeRelationships is set to true.

On your second question, yes. If a key passed to populateFromStruct matches a property in the target entity, the populator will try to compose the relationship represented by the key.

ah. i assumed it was set to false because i dont pass in that param and it defaults to false in the method.

dumping the args, COMPOSERELATIONSHIPS is set to true and thats why it was using the array as PK IDs.

thanks