/**
  * Used to retrieve a fieldname for either field or association from a given column,
  *
  * This method is used in foreign-key as primary-key contexts.
  *
  * @param  string $columnName
  * @throws MappingException
  * @return string
  */
 public function getFieldForColumn($columnName)
 {
     if (isset($this->fieldNames[$columnName])) {
         return $this->fieldNames[$columnName];
     } else {
         foreach ($this->associationMappings as $assocName => $mapping) {
             if ($this->isAssociationWithSingleJoinColumn($assocName) && $this->associationMappings[$assocName]['joinColumns'][0]['name'] == $columnName) {
                 return $assocName;
             }
         }
         throw MappingException::noFieldNameFoundForColumn($this->name, $columnName);
     }
 }