private FieldDescriptor getFldFromReference ( TableAlias aTableAlias , ObjectReferenceDescriptor anOrd ) { FieldDescriptor fld = null ; if ( aTableAlias == getRoot ( ) ) { // no path expression FieldDescriptor [ ] fk = anOrd . getForeignKeyFieldDescriptors ( aTableAlias . cld ) ; if ( fk . length > 0 ) { fld = fk [ 0 ] ; } } else { // attribute with path expression /** * MBAIRD * potentially people are referring to objects, not to the object's primary key, * and then we need to take the primary key attribute of the referenced object * to help them out. */ ClassDescriptor cld = aTableAlias . cld . getRepository ( ) . getDescriptorFor ( anOrd . getItemClass ( ) ) ; if ( cld != null ) { fld = aTableAlias . cld . getFieldDescriptorByName ( cld . getPkFields ( ) [ 0 ] . getPersistentField ( ) . getName ( ) ) ; } } return fld ; }
Get FieldDescriptor from Reference