Skip to content

Commit 3dafdeb

Browse files
committed
COLDBOX-1325 #resolve
populator discover entity name not accouting for missing entityname
1 parent 5c9cdd8 commit 3dafdeb

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

system/core/dynamic/BeanPopulator.cfc

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -414,16 +414,19 @@ component {
414414
}
415415
// 3.) component lookup
416416
else {
417-
try {
418-
targetEntityName = getComponentMetadata( relationalMeta[ key ].cfc ).entityName;
419-
} catch ( any e ) {
420-
throw(
421-
type = "BeanPopulator.PopulateBeanException",
422-
message = "Error populating bean #getMetadata( beanInstance ).name# relationship of #key#. The component #relationalMeta[ key ].cfc# could not be found.",
423-
detail = "#e.Detail#<br>#e.message#<br>#e.tagContext.toString()#"
424-
);
417+
var annotations = server.keyExists( "boxlang" ) ? getClassMetadata( arguments.relationalMeta.properties[ key ].cfc ).annotations : getComponentMetadata( arguments.relationalMeta.properties[ key ].cfc );
418+
if( annotations.keyExists( "entityName" ) ){
419+
targetEntityName = annotations.entityName;
425420
}
426421
}
422+
423+
if( !len( targetEntityName ) ){
424+
throw(
425+
type = "ObjectPopulator.PopulateObjectException",
426+
message = "Error populating object [#getMetadata( arguments.target ).name#] relationship of [#key#]. The class [#arguments.relationalMeta.properties[ key ].cfc#] could not be found.",
427+
);
428+
}
429+
427430
// if targetEntityName was successfully found
428431
if ( len( targetEntityName ) ) {
429432
// array or struct type (one-to-many, many-to-many)

0 commit comments

Comments
 (0)