[DDC-1376] Foreign key not available to order when using findBy() Created: 14/Sep/11  Updated: 14/Jan/13  Resolved: 14/Jan/13

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: ORM
Affects Version/s: 2.1.1
Fix Version/s: 2.4
Security Level: All

Type: Improvement Priority: Major
Reporter: Presteus Assignee: Fabio B. Silva
Resolution: Fixed Votes: 0
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



 Comments   
Comment by Benjamin Eberlei [ 15/Sep/11 ]

Not a bug

Comment by Fabio B. Silva [ 14/Jan/13 ]

Fixed : https://github.com/doctrine/doctrine2/commit/b30b06852bc4eacf8bbbed472e1d6ec21310ec0a

Generated at Thu Nov 27 13:31:45 UTC 2014 using JIRA 6.2.3#6260-sha1:63ef1d6dac3f4f4d7db4c1effd405ba38ccdc558.