Doctrine 2 - ORM
  1. Doctrine 2 - ORM
  2. DDC-1376

Foreign key not available to order when using findBy()

    Details

    • Type: Improvement Improvement
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.1.1
    • Fix Version/s: 2.4
    • Component/s: ORM
    • Security Level: All
    • Labels:
      None

      Description

      <?php
      /**
       * Service
       *
       * @Entity(repositoryClass="App_Model_Repository_Si_Service")
       * @Table(name="service")
       */
      class App_Model_Entities_Si_Service
      {
         /**
          * @var int
          *
          * @Id
          * @GeneratedValue(strategy="SEQUENCE")
          * @Column(name="pk", type="integer")
          */
         public $pk;
      
          /**
           * Service parent
           * @var App_Model_Entities_Si_Service
           *
           * @ManyToOne(targetEntity="App_Model_Entities_Si_Service", cascade={"all"}, inversedBy="service")
           * @JoinColumn(name="pk_service", referencedColumnName="pk")
           */
          private $service;
      
         /**
          * Returns an App_Model_Entities_Si_Service that represents the service
          *
          * @return App_Model_Entities_Si_Service
          */
         public function getService(){
            return $this->service;
         }
         /**
          * Set an App_Model_Entities_Si_Service that represents a service
          *
          * @param App_Model_Entities_Si_Service $newService
          */
         public function setService($newService){
            $this->service = $newService;
         }
      }
      
      
      $service = $this->service('Service_Type', true);
      $serviceType = $service->findOneBy(array('code' => 'service'));
              
      $service = $this->service('Service', true);
      $services = $service->findBy(
          array('serviceType' => $serviceType->getPk()),
          array('service' => 'ASC')
      );
      

      Using orderBy parameter of EntityRepository::findBy() with Foreign Key do not work.
      An Unrecognized field error occured.

      Of course, i can use DQL but i think this function should work with mapping.

      Thank you in advance

        Activity

        Presteus created issue -
        Presteus made changes -
        Field Original Value New Value
        Description {code:php}
        $service = $this->service('Service_Type', true);
        $serviceType = $service->findOneBy(array('code' => 'service'));
                
        $service = $this->service('Service', true);
        $services = $service->findBy(
              array('serviceType' => $serviceType),
               array('service' => 'ASC')
        );
        {code}

        Using orderBy parameter of EntityRepository::findBy() with Foreign Key do not work.
        An Unrecognized field error occured.

        Of course, i can use DQL but i think this function should work with mapping.

        Thank you in advance
        {code}
        $service = $this->service('Service_Type', true);
        $serviceType = $service->findOneBy(array('code' => 'service'));
                
        $service = $this->service('Service', true);
        $services = $service->findBy(
              array('serviceType' => $serviceType),
               array('service' => 'ASC')
        );
        {code}

        Using orderBy parameter of EntityRepository::findBy() with Foreign Key do not work.
        An Unrecognized field error occured.

        Of course, i can use DQL but i think this function should work with mapping.

        Thank you in advance
        Presteus made changes -
        Description {code}
        $service = $this->service('Service_Type', true);
        $serviceType = $service->findOneBy(array('code' => 'service'));
                
        $service = $this->service('Service', true);
        $services = $service->findBy(
              array('serviceType' => $serviceType),
               array('service' => 'ASC')
        );
        {code}

        Using orderBy parameter of EntityRepository::findBy() with Foreign Key do not work.
        An Unrecognized field error occured.

        Of course, i can use DQL but i think this function should work with mapping.

        Thank you in advance
        {code}
        $service = $this->service('Service_Type', true);
        $serviceType = $service->findOneBy(array('code' => 'service'));
                
        $service = $this->service('Service', true);
        $services = $service->findBy(
              array('serviceType' => $serviceType->getPk()),
               array('service' => 'ASC')
        );
        {code}

        Using orderBy parameter of EntityRepository::findBy() with Foreign Key do not work.
        An Unrecognized field error occured.

        Of course, i can use DQL but i think this function should work with mapping.

        Thank you in advance
        Presteus made changes -
        Description {code}
        $service = $this->service('Service_Type', true);
        $serviceType = $service->findOneBy(array('code' => 'service'));
                
        $service = $this->service('Service', true);
        $services = $service->findBy(
              array('serviceType' => $serviceType->getPk()),
               array('service' => 'ASC')
        );
        {code}

        Using orderBy parameter of EntityRepository::findBy() with Foreign Key do not work.
        An Unrecognized field error occured.

        Of course, i can use DQL but i think this function should work with mapping.

        Thank you in advance
        {code}
        $service = $this->service('Service_Type', true);
        $serviceType = $service->findOneBy(array('code' => 'service'));
                
        $service = $this->service('Service', true);
        $services = $service->findBy(
            array('serviceType' => $serviceType->getPk()),
            array('service' => 'ASC')
        );
        {code}

        Using orderBy parameter of EntityRepository::findBy() with Foreign Key do not work.
        An Unrecognized field error occured.

        Of course, i can use DQL but i think this function should work with mapping.

        Thank you in advance
        Presteus made changes -
        Description {code}
        $service = $this->service('Service_Type', true);
        $serviceType = $service->findOneBy(array('code' => 'service'));
                
        $service = $this->service('Service', true);
        $services = $service->findBy(
            array('serviceType' => $serviceType->getPk()),
            array('service' => 'ASC')
        );
        {code}

        Using orderBy parameter of EntityRepository::findBy() with Foreign Key do not work.
        An Unrecognized field error occured.

        Of course, i can use DQL but i think this function should work with mapping.

        Thank you in advance
        {code}
        <?php
        /**
         * Services
         * This class represents
         *
         * @package moo
         * @author jlebreton
         * @license http://www.php.net/license/3_01.txt PHP License 3.01
         * @since 0.0
         *
         * @Entity(repositoryClass="App_Model_Repository_Si_Service")
         * @Table(name="service")
         */
        class App_Model_Entities_Si_Service
        {
           /**
            * @var int
            *
            * @Id

            * @GeneratedValue(strategy="SEQUENCE")
            * @Column(name="pk", type="integer")
            */
           public $pk;

            /**
             * Service parent
             * @var App_Model_Entities_Si_Service
             *
             * @ManyToOne(targetEntity="App_Model_Entities_Si_Service", cascade={"all"}, inversedBy="service")
             * @JoinColumn(name="pk_service", referencedColumnName="pk")
             */
            private $service;

           /**
            * Returns an App_Model_Entities_Si_Service that represents the
            *
            * @return App_Model_Entities_Si_Service
            */
           public function getService(){
              return $this->service;
           }
           /**
            * Set an App_Model_Entities_Si_Service that represents the
            *
            * @param App_Model_Entities_Si_Service $newService
            */
           public function setService($newService){
              $this->service = $newService;
           }
        }

        {code}
        {code}
        $service = $this->service('Service_Type', true);
        $serviceType = $service->findOneBy(array('code' => 'service'));
                
        $service = $this->service('Service', true);
        $services = $service->findBy(
            array('serviceType' => $serviceType->getPk()),
            array('service' => 'ASC')
        );
        {code}

        Using orderBy parameter of EntityRepository::findBy() with Foreign Key do not work.
        An Unrecognized field error occured.

        Of course, i can use DQL but i think this function should work with mapping.

        Thank you in advance
        Presteus made changes -
        Description {code}
        <?php
        /**
         * Services
         * This class represents
         *
         * @package moo
         * @author jlebreton
         * @license http://www.php.net/license/3_01.txt PHP License 3.01
         * @since 0.0
         *
         * @Entity(repositoryClass="App_Model_Repository_Si_Service")
         * @Table(name="service")
         */
        class App_Model_Entities_Si_Service
        {
           /**
            * @var int
            *
            * @Id

            * @GeneratedValue(strategy="SEQUENCE")
            * @Column(name="pk", type="integer")
            */
           public $pk;

            /**
             * Service parent
             * @var App_Model_Entities_Si_Service
             *
             * @ManyToOne(targetEntity="App_Model_Entities_Si_Service", cascade={"all"}, inversedBy="service")
             * @JoinColumn(name="pk_service", referencedColumnName="pk")
             */
            private $service;

           /**
            * Returns an App_Model_Entities_Si_Service that represents the
            *
            * @return App_Model_Entities_Si_Service
            */
           public function getService(){
              return $this->service;
           }
           /**
            * Set an App_Model_Entities_Si_Service that represents the
            *
            * @param App_Model_Entities_Si_Service $newService
            */
           public function setService($newService){
              $this->service = $newService;
           }
        }

        {code}
        {code}
        $service = $this->service('Service_Type', true);
        $serviceType = $service->findOneBy(array('code' => 'service'));
                
        $service = $this->service('Service', true);
        $services = $service->findBy(
            array('serviceType' => $serviceType->getPk()),
            array('service' => 'ASC')
        );
        {code}

        Using orderBy parameter of EntityRepository::findBy() with Foreign Key do not work.
        An Unrecognized field error occured.

        Of course, i can use DQL but i think this function should work with mapping.

        Thank you in advance
        {code}
        <?php
        /**
         * Services

         * @since 0.0
         *
         * @Entity(repositoryClass="App_Model_Repository_Si_Service")
         * @Table(name="service")
         */
        class App_Model_Entities_Si_Service
        {
           /**
            * @var int
            *
            * @Id
            * @GeneratedValue(strategy="SEQUENCE")
            * @Column(name="pk", type="integer")
            */
           public $pk;

            /**
             * Service parent
             * @var App_Model_Entities_Si_Service
             *
             * @ManyToOne(targetEntity="App_Model_Entities_Si_Service", cascade={"all"}, inversedBy="service")
             * @JoinColumn(name="pk_service", referencedColumnName="pk")
             */
            private $service;

           /**
            * Returns an App_Model_Entities_Si_Service that represents the service
            *
            * @return App_Model_Entities_Si_Service
            */
           public function getService(){
              return $this->service;
           }
           /**
            * Set an App_Model_Entities_Si_Service that represents a service
            *
            * @param App_Model_Entities_Si_Service $newService
            */
           public function setService($newService){
              $this->service = $newService;
           }
        }

        {code}
        {code}
        $service = $this->service('Service_Type', true);
        $serviceType = $service->findOneBy(array('code' => 'service'));
                
        $service = $this->service('Service', true);
        $services = $service->findBy(
            array('serviceType' => $serviceType->getPk()),
            array('service' => 'ASC')
        );
        {code}

        Using orderBy parameter of EntityRepository::findBy() with Foreign Key do not work.
        An Unrecognized field error occured.

        Of course, i can use DQL but i think this function should work with mapping.

        Thank you in advance
        Presteus made changes -
        Description {code}
        <?php
        /**
         * Services

         * @since 0.0
         *
         * @Entity(repositoryClass="App_Model_Repository_Si_Service")
         * @Table(name="service")
         */
        class App_Model_Entities_Si_Service
        {
           /**
            * @var int
            *
            * @Id
            * @GeneratedValue(strategy="SEQUENCE")
            * @Column(name="pk", type="integer")
            */
           public $pk;

            /**
             * Service parent
             * @var App_Model_Entities_Si_Service
             *
             * @ManyToOne(targetEntity="App_Model_Entities_Si_Service", cascade={"all"}, inversedBy="service")
             * @JoinColumn(name="pk_service", referencedColumnName="pk")
             */
            private $service;

           /**
            * Returns an App_Model_Entities_Si_Service that represents the service
            *
            * @return App_Model_Entities_Si_Service
            */
           public function getService(){
              return $this->service;
           }
           /**
            * Set an App_Model_Entities_Si_Service that represents a service
            *
            * @param App_Model_Entities_Si_Service $newService
            */
           public function setService($newService){
              $this->service = $newService;
           }
        }

        {code}
        {code}
        $service = $this->service('Service_Type', true);
        $serviceType = $service->findOneBy(array('code' => 'service'));
                
        $service = $this->service('Service', true);
        $services = $service->findBy(
            array('serviceType' => $serviceType->getPk()),
            array('service' => 'ASC')
        );
        {code}

        Using orderBy parameter of EntityRepository::findBy() with Foreign Key do not work.
        An Unrecognized field error occured.

        Of course, i can use DQL but i think this function should work with mapping.

        Thank you in advance
        {code}
        <?php
        /**
         * Service
         *
         * @Entity(repositoryClass="App_Model_Repository_Si_Service")
         * @Table(name="service")
         */
        class App_Model_Entities_Si_Service
        {
           /**
            * @var int
            *
            * @Id
            * @GeneratedValue(strategy="SEQUENCE")
            * @Column(name="pk", type="integer")
            */
           public $pk;

            /**
             * Service parent
             * @var App_Model_Entities_Si_Service
             *
             * @ManyToOne(targetEntity="App_Model_Entities_Si_Service", cascade={"all"}, inversedBy="service")
             * @JoinColumn(name="pk_service", referencedColumnName="pk")
             */
            private $service;

           /**
            * Returns an App_Model_Entities_Si_Service that represents the service
            *
            * @return App_Model_Entities_Si_Service
            */
           public function getService(){
              return $this->service;
           }
           /**
            * Set an App_Model_Entities_Si_Service that represents a service
            *
            * @param App_Model_Entities_Si_Service $newService
            */
           public function setService($newService){
              $this->service = $newService;
           }
        }

        {code}
        {code}
        $service = $this->service('Service_Type', true);
        $serviceType = $service->findOneBy(array('code' => 'service'));
                
        $service = $this->service('Service', true);
        $services = $service->findBy(
            array('serviceType' => $serviceType->getPk()),
            array('service' => 'ASC')
        );
        {code}

        Using orderBy parameter of EntityRepository::findBy() with Foreign Key do not work.
        An Unrecognized field error occured.

        Of course, i can use DQL but i think this function should work with mapping.

        Thank you in advance
        Benjamin Eberlei made changes -
        Issue Type Bug [ 1 ] Improvement [ 4 ]
        Benjamin Eberlei made changes -
        Workflow jira [ 13019 ] jira-feedback [ 13968 ]
        Benjamin Eberlei made changes -
        Workflow jira-feedback [ 13968 ] jira-feedback2 [ 15832 ]
        Benjamin Eberlei made changes -
        Workflow jira-feedback2 [ 15832 ] jira-feedback3 [ 18088 ]
        Fabio B. Silva made changes -
        Assignee Benjamin Eberlei [ beberlei ] Fabio B. Silva [ fabio.bat.silva ]
        Fabio B. Silva made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Fix Version/s 2.4 [ 10321 ]
        Resolution Fixed [ 1 ]

          People

          • Assignee:
            Fabio B. Silva
            Reporter:
            Presteus
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: