DDC-2434: Error generating entities using annotation docblock (in php). Attribute "fetch" is not being generated by Class EntityGenerator #3149

Closed
doctrinebot opened this Issue May 7, 2013 · 3 comments

2 participants

@doctrinebot

Jira issue originally created by user coisa2004:

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

@doctrinebot

Comment created by @beberlei:

Highlighted code

@doctrinebot

Comment created by @beberlei:

Fixed and will be included in 2.3.4 release

@doctrinebot

Issue was closed with resolution "Fixed"

@beberlei beberlei was assigned by doctrinebot Dec 6, 2015
@doctrinebot doctrinebot added this to the 2.3.4 milestone Dec 6, 2015
@doctrinebot doctrinebot closed this Dec 6, 2015
@doctrinebot doctrinebot added the Bug label Dec 7, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment