Doctrine 2 - ORM
  1. Doctrine 2 - ORM
  2. DDC-2434

Error generating entities using annotation docblock (in php). Attribute "fetch" is not being generated by Class EntityGenerator

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Critical Critical
    • Resolution: Fixed
    • Affects Version/s: 2.3.3
    • Fix Version/s: 2.3.4
    • Component/s: Tools
    • Security Level: All
    • Labels:
      None
    • Environment:
      Windows xp, Apache 2.2 and PHP 5.3.15

      Description

      In this part of the code that begins on line 1047 which is generated lines docblock but not being generated attribute fetch.

                  $type = null;
                  switch ($associationMapping['type']) {
                      case ClassMetadataInfo::ONE_TO_ONE:
                          $type = 'OneToOne';
                          break;
                      case ClassMetadataInfo::MANY_TO_ONE:
                          $type = 'ManyToOne';
                          break;
                      case ClassMetadataInfo::ONE_TO_MANY:
                          $type = 'OneToMany';
                          break;
                      case ClassMetadataInfo::MANY_TO_MANY:
                          $type = 'ManyToMany';
                          break;
                  }
                  $typeOptions = array();
      
                  if (isset($associationMapping['targetEntity'])) {
                      $typeOptions[] = 'targetEntity="' . $associationMapping['targetEntity'] . '"';
                  }
      
                  if (isset($associationMapping['inversedBy'])) {
                      $typeOptions[] = 'inversedBy="' . $associationMapping['inversedBy'] . '"';
                  }
      
                  if (isset($associationMapping['mappedBy'])) {
                      $typeOptions[] = 'mappedBy="' . $associationMapping['mappedBy'] . '"';
                  }
      
                  if ($associationMapping['cascade']) {
                      $cascades = array();
      
                      if ($associationMapping['isCascadePersist']) $cascades[] = '"persist"';
                      if ($associationMapping['isCascadeRemove']) $cascades[] = '"remove"';
                      if ($associationMapping['isCascadeDetach']) $cascades[] = '"detach"';
                      if ($associationMapping['isCascadeMerge']) $cascades[] = '"merge"';
                      if ($associationMapping['isCascadeRefresh']) $cascades[] = '"refresh"';
      
                      $typeOptions[] = 'cascade={' . implode(',', $cascades) . '}';
                  }
      
                  if (isset($associationMapping['orphanRemoval']) && $associationMapping['orphanRemoval']) {
                      $typeOptions[] = 'orphanRemoval=' . ($associationMapping['orphanRemoval'] ? 'true' : 'false');
                  }
      

      Below is one possible solution.

                  $typesFetch = array(
                      2 => 'LAZY',
                      3 => 'EAGER',
                      4 => 'EXTRA_LAZY'
                  );
      
                  if(isset($associationMapping['fetch'])) {
                      $typeOptions[] = 'fetch="' . $typesFetch[$associationMapping['fetch']] . '"';
                  }
      

      Tanks

        Activity

        Hide
        Benjamin Eberlei added a comment -

        Highlighted code

        Show
        Benjamin Eberlei added a comment - Highlighted code
        Hide
        Benjamin Eberlei added a comment -

        Fixed and will be included in 2.3.4 release

        Show
        Benjamin Eberlei added a comment - Fixed and will be included in 2.3.4 release

          People

          • Assignee:
            Benjamin Eberlei
            Reporter:
            André Antônio Lemos de Moraes
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: