Details

    • Type: Improvement
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 2.2.2
    • Fix Version/s: None
    • Component/s: ORM
    • Labels:
      None
    • Environment:
      php 5.4.3, symfony2.1-dev
      php 5.5.12, symfony 2.5

      Description

      When a trait with included setters and getters is used and generate entities is called, doctrine add another set of getters and setters to the "main" entity where the trait is used.

        Activity

        lunetics Matthias Breddin created issue -
        beberlei Benjamin Eberlei made changes -
        Field Original Value New Value
        Workflow jira [ 13708 ] jira-feedback [ 14067 ]
        beberlei Benjamin Eberlei made changes -
        Workflow jira-feedback [ 14067 ] jira-feedback2 [ 15931 ]
        beberlei Benjamin Eberlei made changes -
        Workflow jira-feedback2 [ 15931 ] jira-feedback3 [ 18182 ]
        asm89 Alexander made changes -
        Issue Type Bug [ 1 ] Improvement [ 4 ]
        Hide
        lsv20 Martin Aarhof added a comment - - edited
        /**
         * @ORM\Entity
         */
        class Product {
            use Traits\Created;
        
            /**
             * @var integer
             *
             * @ORM\Column(name="id", type="integer")
             * @ORM\Id
             * @ORM\GeneratedValue(strategy="AUTO")
             */
            private $id;
        
            /**
             * @var string
             *
             * @ORM\Column(name="name", type="string", length=255)
             */
            private $name;
        
            /**
             * Set name
             *
             * @param string $name
             * @return Attribute
             */
            public function setName($name)
            {
                $this->name = $name;
        
                return $this;
            }
        
            /**
             * Get name
             *
             * @return string 
             */
            public function getName()
            {
                return $this->name;
            }
        
        }
        
        Trait Created {
            /**
             * @var \DateTime $created
             *
             * @Gedmo\Timestampable(on="create")
             * @ORM\Column(type="datetime")
             */
            private $created;
        
            /**
             * @return \DateTime
             */
            public function getCreated()
            {
                return $this->created;
            }
        }
        

        Now when I run php app/console doctrine:generate:entities it copies everything from the trait and into the entity, so the entity now looks like

        /**
         * @ORM\Entity
         */
        class Product {
            use Traits\Created;
        
            /**
             * @var integer
             *
             * @ORM\Column(name="id", type="integer")
             * @ORM\Id
             * @ORM\GeneratedValue(strategy="AUTO")
             */
            private $id;
        
            /**
             * @var string
             *
             * @ORM\Column(name="name", type="string", length=255)
             */
            private $name;
        
            /**
             * Set name
             *
             * @param string $name
             * @return Attribute
             */
            public function setName($name)
            {
                $this->name = $name;
        
                return $this;
            }
        
            /**
             * Get name
             *
             * @return string 
             */
            public function getName()
            {
                return $this->name;
            }
        
            /**
             * @var \DateTime $created
             *
             * @Gedmo\Timestampable(on="create")
             * @ORM\Column(type="datetime")
             */
            private $created;
        
            /**
             * @return \DateTime
             */
            public function getCreated()
            {
                return $this->created;
            }
        
        }
        

        And ofcourse invalidates the entity because it now has two methods of the getCreated and two of private $created

        Show
        lsv20 Martin Aarhof added a comment - - edited /** * @ORM\Entity */ class Product { use Traits\Created; /** * @var integer * * @ORM\Column(name="id", type="integer") * @ORM\Id * @ORM\GeneratedValue(strategy="AUTO") */ private $id; /** * @var string * * @ORM\Column(name="name", type="string", length=255) */ private $name; /** * Set name * * @param string $name * @return Attribute */ public function setName($name) { $this->name = $name; return $this; } /** * Get name * * @return string */ public function getName() { return $this->name; } } Trait Created { /** * @var \DateTime $created * * @Gedmo\Timestampable(on="create") * @ORM\Column(type="datetime") */ private $created; /** * @return \DateTime */ public function getCreated() { return $this->created; } } Now when I run php app/console doctrine:generate:entities it copies everything from the trait and into the entity, so the entity now looks like /** * @ORM\Entity */ class Product { use Traits\Created; /** * @var integer * * @ORM\Column(name="id", type="integer") * @ORM\Id * @ORM\GeneratedValue(strategy="AUTO") */ private $id; /** * @var string * * @ORM\Column(name="name", type="string", length=255) */ private $name; /** * Set name * * @param string $name * @return Attribute */ public function setName($name) { $this->name = $name; return $this; } /** * Get name * * @return string */ public function getName() { return $this->name; } /** * @var \DateTime $created * * @Gedmo\Timestampable(on="create") * @ORM\Column(type="datetime") */ private $created; /** * @return \DateTime */ public function getCreated() { return $this->created; } } And ofcourse invalidates the entity because it now has two methods of the getCreated and two of private $created
        lsv20 Martin Aarhof made changes -
        Priority Minor [ 4 ] Major [ 3 ]
        lsv20 Martin Aarhof made changes -
        Environment php 5.4.3, symfony2.1-dev php 5.4.3, symfony2.1-dev
        php 5.5.12, symfony 2.5
        Hide
        wilgert Wilgert Velinga added a comment -

        Unfortunately I am also suffering from this bug. Is there anything I can do to help resolve it?

        Show
        wilgert Wilgert Velinga added a comment - Unfortunately I am also suffering from this bug. Is there anything I can do to help resolve it?
        Hide
        ludwig.ruderstaller Ludwig Ruderstaller added a comment -

        Same here - i think an easy fix would be to introduce an additional parameter, which if set, ignores all traits.

        Show
        ludwig.ruderstaller Ludwig Ruderstaller added a comment - Same here - i think an easy fix would be to introduce an additional parameter, which if set, ignores all traits.

        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={expand=changesets[0:20].revisions[0:29],reviews, query=DDC-1825}, methodType=GET}] : Received status code 503 (Service Temporarily Unavailable)

          People

          • Assignee:
            beberlei Benjamin Eberlei
            Reporter:
            lunetics Matthias Breddin
          • Votes:
            7 Vote for this issue
            Watchers:
            7 Start watching this issue

            Dates

            • Created:
              Updated: