Doctrine 2 - ORM
  1. Doctrine 2 - ORM
  2. DDC-1579

MappedSuperClass and inheritance problem with console generate:entities command

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Duplicate
    • Affects Version/s: 2.1.5
    • Fix Version/s: 2.3
    • Component/s: Tools
    • Security Level: All
    • Labels:
      None
    • Environment:
      Debian 6.0.3 - Linux 2.6.32-5-amd64

      Symfony2 2.0.8 + Doctrine2 2.1.5

      Description

      I have two classes.

      One extends from another. I'm using the annotation @MappedSuperclass
      and operates correctly, but when he did the entities generation
      through the command console, doctrine adds the property and the
      methods of the "father" class in the subclass.

      This is a bug of the command console?

      Really you should not copy them if you do not extend them. When you
      run the update of the database schema, i must delete these fields and
      methods added to obtain the desired result.

      What happens?

      Im usign Symfony 2.

      Thanks!!!!

      Code:

      Father class:

      /********************************************************************

      /**

      • @ORM\MappedSuperclass
        */
        abstract class ConfigBase
        {

      /**

      • @ORM\Column(name="enabled", type="boolean")
        */
        protected $enabled;

      /**

      • Set enabled
        *
      • @param boolean $enabled
        */
        public function setEnabled($enabled) { $this->enabled = $enabled; }

        /**
        * Get enabled
        *
        * @return boolean
        */
        public function getEnabled()
        { return $this->enabled; }

        }

        /********************************************************************

        SubClass

        /********************************************************************

        /**
        * @ORM\Entity
        *
        */
        class UserConfig extends ConfigBase
        {
        /**
        * @var integer $id
        *
        * @ORM\Column(name="id", type="integer")
        * @ORM\Id
        * @ORM\GeneratedValue(strategy="AUTO")
        */
        protected $id;

        /**
        * Get id
        *
        * @return integer
        */
        public function getId()
        { return $this->id; }

        /************************************************/
        /* Auto generated and non desired values */
        /************************************************/
        /**
        * @var boolean $enabled
        */
        private $enabled;

        /**
        * Set enabled
        *
        * @param boolean $enabled
        */
        public function setEnabled($enabled)
        { $this->enabled = $enabled; }

      /**

      • Get enabled
        *
      • @return boolean
        */
        public function getEnabled() { return $this->enabled; }

        Issue Links

          Activity

          Sergio Moya created issue -
          Benjamin Eberlei made changes -
          Field Original Value New Value
          Link This issue depends on DDC-1590 [ DDC-1590 ]
          Hide
          Benjamin Eberlei added a comment -

          It is a known problem that will be fixed in 2.3 hopefully.

          Show
          Benjamin Eberlei added a comment - It is a known problem that will be fixed in 2.3 hopefully.
          Benjamin Eberlei made changes -
          Status Open [ 1 ] Resolved [ 5 ]
          Fix Version/s 2.3 [ 10185 ]
          Resolution Duplicate [ 3 ]
          Hide
          Johan Hendrik Ehlers added a comment -

          I just noticed that this is only an issue if the member has a protected scope in the mapped super class, it works fine for private members.

          Show
          Johan Hendrik Ehlers added a comment - I just noticed that this is only an issue if the member has a protected scope in the mapped super class, it works fine for private members.
          Benjamin Eberlei made changes -
          Workflow jira [ 13330 ] jira-feedback [ 15179 ]
          Benjamin Eberlei made changes -
          Workflow jira-feedback [ 15179 ] jira-feedback2 [ 17043 ]
          Benjamin Eberlei made changes -
          Workflow jira-feedback2 [ 17043 ] jira-feedback3 [ 19296 ]
          Hide
          Lukas Domnick added a comment -

          As of Doctrine 2.3.0, Symfony 2.1.3, this behaviour is still reproducable.
          Mr. Ehlers is correct; generation will work correctly when the super class' properties are set to private scope. However, in that case the Proxy Object's lazy loading can't set the properties in question.

          Show
          Lukas Domnick added a comment - As of Doctrine 2.3.0, Symfony 2.1.3, this behaviour is still reproducable. Mr. Ehlers is correct; generation will work correctly when the super class' properties are set to private scope. However, in that case the Proxy Object's lazy loading can't set the properties in question.

          This list may be incomplete, as errors occurred whilst retrieving source from linked applications:

          • Request to http://www.doctrine-project.org/fisheye/ failed: Error in remote call to 'FishEye 0 (http://www.doctrine-project.org/fisheye/)' (http://www.doctrine-project.org/fisheye) [AbstractRestCommand{path='/rest-service-fe/search-v1/crossRepositoryQuery', params={query=DDC-1579, expand=changesets[0:20].revisions[0:29],reviews}, methodType=GET}] : Received status code 503 (Service Temporarily Unavailable)

            People

            • Assignee:
              Benjamin Eberlei
              Reporter:
              Sergio Moya
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: