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

Closed
opened 2026-01-22 14:10:49 +01:00 by admin · 3 comments
Owner

Originally created by @doctrinebot on GitHub (May 7, 2013).

Originally assigned to: @beberlei on GitHub.

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

Originally created by @doctrinebot on GitHub (May 7, 2013). Originally assigned to: @beberlei on GitHub. 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
admin added the Bug label 2026-01-22 14:10:49 +01:00
admin closed this issue 2026-01-22 14:10:49 +01:00
Author
Owner

@doctrinebot commented on GitHub (May 9, 2013):

Comment created by @beberlei:

Highlighted code

@doctrinebot commented on GitHub (May 9, 2013): Comment created by @beberlei: Highlighted code
Author
Owner

@doctrinebot commented on GitHub (May 9, 2013):

Comment created by @beberlei:

Fixed and will be included in 2.3.4 release

@doctrinebot commented on GitHub (May 9, 2013): Comment created by @beberlei: Fixed and will be included in 2.3.4 release
Author
Owner

@doctrinebot commented on GitHub (May 9, 2013):

Issue was closed with resolution "Fixed"

@doctrinebot commented on GitHub (May 9, 2013): Issue was closed with resolution "Fixed"
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#3052